Reply
 
Thread Tools Display Modes
  #1   Report Post  
M
 
Posts: n/a
Default mail merge hyperlinks in Word 2003

Is there a trick to keeping hyperlinks when using the Mail Merge feature in
Word 2003 for html emails, I've tried every combination??

Thanks,
M
  #2   Report Post  
Peter Jamieson
 
Posts: n/a
Default

As far as I know:
a. as a general rule, you cannot guarantee that HTML features will work as
you hope because the recipient's email client may not be configured to
display them (or may not be able to do so). But...
b. you have to use a { HYPERLINK } field in Word
c. a link has two parts: a display text, which is what the user actually
sees in the message they receive, and a link text, which is the target that
will be opened if the user clicks the link.
d. as long as your link is fixed and you have inserted it with the correct
display text and link text, and Word has recognised it and turned it into a
{ HYPERLINK } field, the link should be preserved
e. if you are trying to insert hyperlinks "on the fly", e.g. getting the
link text from a field in your merge data source, the problem is that
although the link text may be updated if you insert the link correctly, the
display text is never changed after the { HYPERLINK } field has been
created. You can only change the display text programmatically.
f. so the only way I know to get around this when merging to e-mail is to
use the Word MailMerge events to insert a completely new Hyperlink field for
each record in the data source.


If you want to go that route, you need to look up Word Events from the Help
function in the VBA editor, but for example, if your data source has a
column "displaytext" containing the display text you want, and "linktext"
containing the link text you want, if you insert a Word bookmark at the
point where you want the link and use the following code in the
MailMergeBeforeRecordMerge event you may get what you want:

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.
lt = Doc.MailMerge.DataSource.DataFields("linktext")

' set up the display text that you want.
dt = Doc.MailMerge.DataSource.DataFields("displaytext")

'Or 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 next time

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

Set r = Nothing
Set h = Nothing

End Sub

Peter Jamieson
"M" wrote in message
...
Is there a trick to keeping hyperlinks when using the Mail Merge feature
in
Word 2003 for html emails, I've tried every combination??

Thanks,
M



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
Macros - Keyboard Commands Janet Microsoft Word Help 6 April 11th 05 05:28 AM
Merge in Word 2003 Giovanny Medina via OfficeKB.com Mailmerge 0 February 10th 05 02:42 PM
faxing from word 2003 mail merge Jo_Wizz Mailmerge 2 January 25th 05 11:31 AM
How do I create & merge specific data base & master documents? maggiev New Users 2 January 12th 05 11:30 PM
Word-Excel 2003 - Mail Merge Recipients problem AYager Mailmerge 2 January 11th 05 04:11 AM


All times are GMT +1. The time now is 08:41 PM.

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"