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 / August 2007

Tip: Looking for answers? Try searching our database.

how to preserve the bookmark while using mailmerge feature

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sanjeev - 30 Jul 2007 12:20 GMT
Hi,

  I have a word document which contains many bookmarks , after using the
'Mail merge' feature the bookmarks are removed, Is there a way to solve it.

Thanks in Advance
Graham Mayor - 30 Jul 2007 12:29 GMT
Bookmarks must be unique, the very nature of merge would require the same
bookmarks for each record, so they are stripped from the merge.

Signature

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  Word MVP

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

> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks in Advance
Doug Robbins - Word MVP - 30 Jul 2007 20:57 GMT
' Throwaway Macro created by Doug Robbins to "preserve" 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",
"bookmark" & i) = abm.Name & Format(j)
       i = i + 1
   Next
Next j
For Each abm In ActiveDocument.Range.Bookmarks
   abm.Range.InsertBefore "#"
   abm.Range.InsertAfter "#"
Next
With ActiveDocument.MailMerge
   .Destination = wdSendToNewDocument
   .Execute
End With
Set Result = ActiveDocument
k = 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
   Do While .Execute(FindText:="#*#", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
       Set bmrange = Selection.Range
       bmrange.Characters(bmrange.Characters.Count).Delete
       bmrange.Characters(1).Delete
       Result.Bookmarks.Add System.PrivateProfileString("c:\bookmarks.txt",
"bookmarkNames", "bookmark" & k), bmrange
       k = k + 1
   Loop
End With
For i = 1 To Result.Hyperlinks.Count
   linktarget = Result.Hyperlinks(i).SubAddress
   Set linkrange = Result.Hyperlinks(i).Range
   linkrange.Select
   linktarget = linktarget &
Format(Selection.Information(wdActiveEndSectionNumber))
   Result.Hyperlinks.Add Result.Hyperlinks(i).Range, "", linktarget
Next i

Source.Activate
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
   Do While .Execute(FindText:="#*#", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
       Set bmrange = Selection.Range
       bmrange.Characters(bmrange.Characters.Count).Delete
       bmrange.Characters(1).Delete
   Loop
End With

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

> Hi,
>
[quoted text clipped - 3 lines]
>
> Thanks in Advance
sanjeev - 31 Jul 2007 14:40 GMT
Hi Robins,

Thanks a lot , It solved my problem
   
Regards
Sanjeev

> ' Throwaway Macro created by Doug Robbins to "preserve" bookmarks during a
> MailMerge
[quoted text clipped - 62 lines]
> >
> > Thanks in Advance
Slash - 20 Aug 2007 22:01 GMT
Hi, this solution looks exactly what I require, but I'm not sure how to place
it in the editor.  What should it be called, i.e. sub name, and how does it
auto run?  Thanks.

>' Throwaway Macro created by Doug Robbins to "preserve" bookmarks during a
>MailMerge
[quoted text clipped - 60 lines]
>>
>> Thanks in Advance
Slash - 20 Aug 2007 22:01 GMT
Hi, this solution looks exactly what I require, but I'm not sure how to place
it in the editor.  What should it be called, i.e. sub name, and how does it
auto run?  Thanks.

>' Throwaway Macro created by Doug Robbins to "preserve" bookmarks during a
>MailMerge
[quoted text clipped - 60 lines]
>>
>> Thanks in Advance
 
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.