Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
ProS[_2_] ProS[_2_] is offline
external usenet poster
 
Posts: 1
Default Mailmerge and Hyperlinks


When trying to automate a hyperlink to incorporate a code from a
mailmerge document, the hyperlink won't change.

A mailmerge field, is : {MERGEFIELD(text/code) *\MERGEFORMAT}

A hyperlink is: {HYPERLINK(website) *\MERGEFORMAT}

however, if you direct the hyperlink to the mergefield, it doesn't
work, I know this is due the address specified when first creating the
hyperlink, but is there a way of tricking word into automatically
updating the hyperlink, based on the merge code?




--
ProS
  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Mailmerge and Hyperlinks

If you are trying to create something like

{Hyperlink "{Mergefield WebAddress}"}

then merge to a new document, select the document and press F9 to update the
fields.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


ProS wrote:
When trying to automate a hyperlink to incorporate a code from a
mailmerge document, the hyperlink won't change.

A mailmerge field, is : {MERGEFIELD(text/code) *\MERGEFORMAT}

A hyperlink is: {HYPERLINK(website) *\MERGEFORMAT}

however, if you direct the hyperlink to the mergefield, it doesn't
work, I know this is due the address specified when first creating the
hyperlink, but is there a way of tricking word into automatically
updating the hyperlink, based on the merge code?



  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
ProS[_3_] ProS[_3_] is offline
external usenet poster
 
Posts: 1
Default Mailmerge and Hyperlinks


Thank you for your response, unfortunately it doesn't work for my
purpose.

For example, if I want to automatically direct someone to the hompage
of a website, andn someone else in the mailing list to the downloads
section, and I know where I want each person to be directed to then I
would (theoretically) do a version of your advice:

{Hyperlink "{WebAddress Mergefield(homepage) }"} (person a)


{Hyperlink "{WebAddress Mergefield(downlaods) }"} (person b)

My problem is that when I add the mergefield to the hyperlink either:
It is no longer a hyperlink, it is just text
or the hyperlinked text works but not with the addition of the
mergefield text
or it states that that website doesn't exist

(Do you possibly have any further advice/experience with this?)




--
ProS
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Mailmerge and Hyperlinks

Insert a Hyperlink into the merge document to give you the Web Address
tooltip, which I am pretty sure is not configurable from the fields. Toggle
the hyperlink field (ALT+F9) and replace the web address with the Mergefield
that contains the web address. Update the field and toggle the display back
again. You should then be able to merge to a new document as previously
suggested.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org


ProS wrote:
Thank you for your response, unfortunately it doesn't work for my
purpose.

For example, if I want to automatically direct someone to the hompage
of a website, andn someone else in the mailing list to the downloads
section, and I know where I want each person to be directed to then I
would (theoretically) do a version of your advice:

{Hyperlink "{WebAddress Mergefield(homepage) }"} (person a)


{Hyperlink "{WebAddress Mergefield(downlaods) }"} (person b)

My problem is that when I add the mergefield to the hyperlink either:
It is no longer a hyperlink, it is just text
or the hyperlinked text works but not with the addition of the
mergefield text
or it states that that website doesn't exist

(Do you possibly have any further advice/experience with this?)



  #5   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Mailmerge and Hyperlinks

I think you have to use Word Mail Merge events for this. I have not tested
this recently, but for example:

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 WEBADDRESS for the link. NB, these field names
' are case-sensitive.
lt = Doc.MailMerge.DataSource.DataFields("WEBADDRESS")
' set up the display text that you want. I assuming you have a field
' called WEBTEXT
dt = Doc.MailMerge.DataSource.DataFields("WEBTEXT")

' 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. You should realise
that
once you have enabled the events, they apply to any document until either
you or
Word has disabled them again. This is why I do not particularly like using
Events, but even so,
I suspect that this is the easiest way to perform this particular task in
Word.


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

"ProS" wrote in message
...

Thank you for your response, unfortunately it doesn't work for my
purpose.

For example, if I want to automatically direct someone to the hompage
of a website, andn someone else in the mailing list to the downloads
section, and I know where I want each person to be directed to then I
would (theoretically) do a version of your advice:

{Hyperlink "{WebAddress Mergefield(homepage) }"} (person a)


{Hyperlink "{WebAddress Mergefield(downlaods) }"} (person b)

My problem is that when I add the mergefield to the hyperlink either:
It is no longer a hyperlink, it is just text
or the hyperlinked text works but not with the addition of the
mergefield text
or it states that that website doesn't exist

(Do you possibly have any further advice/experience with this?)




--
ProS




  #6   Report Post  
Posted to microsoft.public.word.mailmerge.fields
ProS[_4_] ProS[_4_] is offline
external usenet poster
 
Posts: 1
Default Mailmerge and Hyperlinks


Thank you. I'll give it a go.




--
ProS
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
Absolute hyperlinks without losing local hyperlinks! 2nd attempt MattM Microsoft Word Help 18 September 30th 09 10:14 PM
Hyperlinks Jar Tables 2 September 17th 07 09:32 AM
Absolute hyperlinks without losing local hyperlinks! MattM Microsoft Word Help 0 May 25th 06 02:55 PM
Hyperlinks in TOC pmdavies Microsoft Word Help 1 August 9th 05 12:34 AM
Using hyperlinks WMSUB New Users 1 March 8th 05 03:33 PM


All times are GMT +1. The time now is 03:04 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"