Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] nick.barrar@siemens.com is offline
external usenet poster
 
Posts: 1
Default How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text.

Hi,

I'm working with MS Access 2003 and MS Word 2003 and what I need to
know is how to create an email from mail merge including a hyperlink,
so that the value of a merged field is included as part of the
hyperlink URL, not just part of its text.

The context for this is that I'm trying to create a survey to be sent
out via email, the survey is transactional and thus I need to include
a unique number in the hyperlink included in each email to make it
work, I'm doing this by merging the unique number from access into the
URL going in the email.

like this:

http://intranet.company.co.uk/custom...icketid=999999

The "99999" has to be the number from access. I can get it into the
link text - but I can't get it to go in the link URL itself.

If this won't work, is there another way, maybe from the Access end?
Can I generate emails directly from Access?

Any help would be greatly appreciated !

Many Thanks,
Nick

  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text.

To specify the display text, things are complicated because there is no
"switch"
in the HYPERLINK field that lets you specify the display text.

You may be able to do the merge using VBA and "Word Events", e.g. as follows
(I haven't tested this recently). Nasty, but even so I suspect this is the
easiest way to do it in Word.

1. Create a new document, connect it to your data source, and insert one
merge field and a bookmark named "mybm"

2. Open up the VBA Editor and
a. insert a class module.
b. name it EventClassModule in the properties box
c. Copy the following code into the module:

Public WithEvents App As Word.Application

Private Sub App_MailMergeBeforeRecordMerge(BYVal Doc As Document, Cancel As
Boolean)
Dim dt as String
Dim lt as String
Dim h as Hyperlink
Dim r as Range

' set the range variable to our placeholder bookmark
Set r = Doc.Bookmarks("mybm").Range

' delete any existing text (this is needed for records after record 1)
r.Text = ""

' construct the link text that you want. I'm assuming your data source
' has a field called mylink for the link
lt = Doc.MailMerge.DataSource.DataFields("mylink")
' set up the display text that you want. If it should be the same as the
link text, do that:
dt = lt

' insert the hyperlink you want
Set h = Doc.Hyperlinks.Add(Anchor:=r, Address=lt, TextToDisplay:=dt)

' Set mybm to "cover" the inserted link so it is easy to delete the old
hyperlink

Doc.Bookmarks.Add Name:="mybm", Range:=h.Range

Set r = Nothing
Set h = Nothing

End Sub

3. Insert an ordinary module (the name does not matter) and insert the
following code:

Dim x As New EventClassModule

Sub autoopen()
Set x.App = Word.Application
End Sub

4. Save and close the document. Open it to trigger the autoopen, then
perform a test merge.

NB, if you start changing the code you may find that you need to re-run your
autoopen code again, and/or save/close/open the document.

Peter Jamieson



wrote in message
oups.com...
Hi,

I'm working with MS Access 2003 and MS Word 2003 and what I need to
know is how to create an email from mail merge including a hyperlink,
so that the value of a merged field is included as part of the
hyperlink URL, not just part of its text.

The context for this is that I'm trying to create a survey to be sent
out via email, the survey is transactional and thus I need to include
a unique number in the hyperlink included in each email to make it
work, I'm doing this by merging the unique number from access into the
URL going in the email.

like this:

http://intranet.company.co.uk/custom...icketid=999999

The "99999" has to be the number from access. I can get it into the
link text - but I can't get it to go in the link URL itself.

If this won't work, is there another way, maybe from the Access end?
Can I generate emails directly from Access?

Any help would be greatly appreciated !

Many Thanks,
Nick


  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] nickbarrar@hotmail.com is offline
external usenet poster
 
Posts: 3
Default How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text.

Peter - I'll try this out and confirm this week, thanks very much for
this, it's greatly appreciated !!!

Nick


  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
[email protected] nickbarrar@hotmail.com is offline
external usenet poster
 
Posts: 3
Default How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text.

On 20 Aug, 13:47, wrote:
Peter - I'll try this out and confirm this week, thanks very much for
this, it's greatly appreciated !!!

Nick


Peter thanks - almost worked but we get a syntax error at;

' insert the hyperlink you want
Set h = Doc.Hyperlinks.Add(Anchor:= r, Address = lt, TextToDisplay:=
dt)

any ideas?

Nick

  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text.


Yes, there should be a colon after address, i.e.

Set h = Doc.Hyperlinks.Add(Anchor:= r, Address:= lt, TextToDisplay:=dt)

--
Peter Jamieson
http://tips.pjmsn.me.uk

wrote in message
oups.com...
On 20 Aug, 13:47, wrote:
Peter - I'll try this out and confirm this week, thanks very much for
this, it's greatly appreciated !!!

Nick


Peter thanks - almost worked but we get a syntax error at;

' insert the hyperlink you want
Set h = Doc.Hyperlinks.Add(Anchor:= r, Address = lt, TextToDisplay:=
dt)

any ideas?

Nick


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlink to a specific part of a web page TBA Microsoft Word Help 1 June 6th 07 03:19 AM
How can I put a hyperlink to a webpage in a mail merge field? Excel one tenth guru Mailmerge 1 March 22nd 07 08:13 AM
How do I keep the merged email address hyperlink LS Mailmerge 1 January 3rd 06 03:33 PM
Mail merge from Access, with hyperlink field troubadour Mailmerge 4 June 11th 05 04:44 PM
Want to Merge WEB CONTENT from merged hyperlink-as-data-field iamphidias Mailmerge 0 February 2nd 05 08:29 PM


All times are GMT +1. The time now is 11:43 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"