Bookmarks are not retained during Mail Merge

L

Latha

Thanks for that Doug. I tried that but an error 'Compile
error: Method or data member not found' occured
at 'RecordCount' of "For j = 1 To
source.MailMerge.DataSource.RecordCount"

-----Original Message-----
The following might do what you want:

' Throwaway Macro created by Doug Robbins to "preserve" hyperlinks to
bookmarks during a MailMerge
'
Dim abm As Bookmark, bmrange As Range, i As Long, Result As Document, j As
Long, k As Long, linkrange As Range, linktarget As String
Dim source As Document
Set source = ActiveDocument
i = 1
For j = 1 To source.MailMerge.DataSource.RecordCount
For Each abm In ActiveDocument.Range.Bookmarks
System.PrivateProfileString
("c:\bookmarks.txt", "bookmarkNames",
 
D

Doug Robbins - Word MVP

That would happen if you ran the macro when the active document was either
not a mailmerge main document and/or it did not have a datasource attached
to it.

The following version checks the .mailmerge.state of the active document and
will tell you whether it is not suitable for the purpose of the macro.

The macro works fine here (though I had to try it about 50 times before I
finally got it right) - I'm actually upto Letters54.

--
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top