Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / January 2006

Tip: Looking for answers? Try searching our database.

Hyperlink with Merge Field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wayne Wengert - 21 May 2005 22:15 GMT
I am using Word 2003 to try to build an email merge that includes a
hyperlink that has a merge field as part of the hyperlink and it is not
working. The email received looks correct as shown here:

============================================
To verify this email address you registered please click on the following
link:

To verify this email address you registered please click on the following
link:

http://westernband.org/verifyemailaddress.aspx/?i=156

=============================================

but the "156" is actually the value of a database field (<<myID>>) and when
I click on the link in the email it actually uses the following as the link

==============================================

http://westernband.org/verifyemailaddress.aspx/?i=<<myID>>

===============================================

How can I get it to replace that field code with a real value?

Wayne
Doug Robbins - 22 May 2005 09:16 GMT
Maybe this information posted by fellow MVP Cindy Meister will help:

Quote

The only way Word can create a hyperlink is using a Hyperlink field. That
means that you have to pass the TEXT (URL) through the mail merge, and nest
the merge field into a Hyperlink field. Further, this has to be done as the
last step, and the mail merge executed immediately, to a NEW document,
before
hiding the merge field codes, then updating the fields.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

Unquote

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

>I am using Word 2003 to try to build an email merge that includes a
>hyperlink that has a merge field as part of the hyperlink and it is not
[quoted text clipped - 24 lines]
>
> Wayne
Wayne Wengert - 22 May 2005 10:17 GMT
Doug;

Thanks for the response but I don't see how to apply that to an Email
Merge - there is no "NEW" document?

Wayns

> Maybe this information posted by fellow MVP Cindy Meister will help:
>
[quoted text clipped - 47 lines]
>>
>> Wayne
Cindy M  -WordMVP- - 22 May 2005 10:52 GMT
Hi Wayne,

> but I don't see how to apply that to an Email
> Merge - there is no "NEW" document?

That's the problem. And when I don't have a lot of time (or
patience for experimenting), that's why I avoid these
questions. There simply is no "simple" answer. FWIW

1. Don't use Word. There's other software out there that's
better for merging to email. You should find a list at
slipstick.com

2. Merge to a new document, then use Doug Robbins's tool
for pulling the result apart and sending it as separate
emails. You should find this on the word.mvps.org site,
labelled as something for emailing with attachments. You
should be able to use (or adapt) it to email without
attachments.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update
Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any
follow question or reply in the newsgroup and not by e-mail
:-)
Wayne Wengert - 22 May 2005 16:38 GMT
Cindy;

Thanks for that information. I'll try an alternate approach. Sure seems like
something that Word should be able to do - maybe Word 2010?

Wayne

> Hi Wayne,
>
[quoted text clipped - 25 lines]
> follow question or reply in the newsgroup and not by e-mail
> :-)
Peter Jamieson - 22 May 2005 18:33 GMT
Another possibility is to use mail merge events and vba to insert the
HYPERLINK fields you need. Here's something I've posted before - probably
needs testing and adaptation but may be worth a try.

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.DataF­ields("linktext")

' set up the display text that you want.
dt = Doc.MailMerge.DataSource.DataF­ields("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

> Cindy;
>
[quoted text clipped - 32 lines]
>> follow question or reply in the newsgroup and not by e-mail
>> :-)
Gary N - 19 Jan 2006 18:07 GMT
Hi Peter,

This code works great!

Is there a way it could be modified so that a image can be used as a merged
hyperlink as well?

Thanks a bunch!

>Another possibility is to use mail merge events and vba to insert the
>HYPERLINK fields you need. Here's something I've posted before - probably
[quoted text clipped - 70 lines]
>>> follow question or reply in the newsgroup and not by e-mail
>>> :-)
Gary N - 19 Jan 2006 20:47 GMT
Hi Peter,

Nevermind, I got the code to work for images as well :-)

Thanks again

>Hi Peter,
>
[quoted text clipped - 10 lines]
>>>> follow question or reply in the newsgroup and not by e-mail
>>>> :-)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.