Reply
 
Thread Tools Display Modes
  #1   Report Post  
ric
 
Posts: n/a
Default mail merge in word should allow hyperlinks to be obtained from a .

mail merge in word should allow hyperlinks to be obtained from a data source.

for example i had the need to send special pages to a large number of people
with a link in it that would redirect to a special personal page through an
URL string.. (www.server.com/default.asp?ID=ID from Database for each
contact)
  #2   Report Post  
Doug Robbins
 
Posts: n/a
Default

I believe that it does with Word XP SP2

--
Please respond to the Newsgroup for the benefit of others who may be
interested. Questions sent directly to me will only be answered on a paid
consulting basis.

Hope this helps,
Doug Robbins - Word MVP
"ric" wrote in message
...
mail merge in word should allow hyperlinks to be obtained from a data
source.

for example i had the need to send special pages to a large number of
people
with a link in it that would redirect to a special personal page through
an
URL string.. (www.server.com/default.asp?ID=ID from Database for each
contact)



  #3   Report Post  
Peter Jamieson
 
Posts: n/a
Default

As Doug says, you will probably need Word XP SP2 or later to make this work
at all, but...

From an old post of mine, slightly edited:

You /may/ be able to get what you want using fields, and someone may come
along and suggest how to do that. But I think you will need to use VBA and
the mailmerge events.If you're familiar with VBA, I suggest you try the
following experiment. If you're familiar with Events, you can probably skip
some of this stuff.

The overview is as follows:
a. In your mail merge main document, you will have a bookmark named "mybm"
that specifies where you want the hyperlink to go
b. also in the document, you have a class module with a routine that
responds to the Mailmerge "Before Record Merge" event. This routine will
insert a hyperlink at the specified point, using data from the current
record in the data source
c. Also in the document, you have a module with an AutoOpen routine that
creates an instance of your class and initialises event handling.

I'm not a VBA expert so please don't regard the following code as
"polished" - you may need to add error handling and so on before it will all
work reliably for you or your users.

So...

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
fields called idfield and namefield
lt = http://www.testsite.com?id= & _
Doc.MailMerge.DataSource.DataFields("idfield") & _
"&name=" & _
Doc.MailMerge.DataSource.DataFields("namefield")
' 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

"ric" wrote in message
...
mail merge in word should allow hyperlinks to be obtained from a data
source.

for example i had the need to send special pages to a large number of
people
with a link in it that would redirect to a special personal page through
an
URL string.. (www.server.com/default.asp?ID=ID from Database for each
contact)



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
Mail merge - Word 2003/Access 2000 Russell Farr Mailmerge 7 March 24th 06 01:03 AM
In typing dates in Word, i.e. "January 12" how do you keep the "1. Carol Microsoft Word Help 2 January 12th 05 09:09 PM
mail merge problem - "Word found locked fields during the update.. zgaryt Tables 1 January 9th 05 02:04 PM
Word 2003 and Access 2003 Mail Merge question HD87glide Microsoft Word Help 2 December 15th 04 03:29 PM
Using Hyperlinks in Mail Merge IF...THEN...ELSE Statements Mark V Mailmerge 8 November 30th 04 02:31 PM


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