If you run the following macro when the mailmerge main document is active,
it will execute the merge to a new document, split that new document into
individual documents with each document corresponding to a record in the
datasource and then it will recreate the bookmarks that were in the main
document in each of those documents and save and close them with a filename
"Letter#" where # is a sequential number:
' 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
Dim Target As Document, Letter As Range, source As Document
Set source = ActiveDocument
i = 1
For Each abm In ActiveDocument.Range.Bookmarks
System.PrivateProfileString("c:\bookmarks.txt", "bookmarkNames",
"bookmark" & i) = abm.Name
abm.Range.InsertBefore "#"
abm.Range.InsertAfter "#"
i = i + 1
Next
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute
End With
Set Result = ActiveDocument
For j = 1 To Result.Sections.Count - 1
Set Letter = Result.Sections(j).Range
Letter.End = Letter.End - 1
Set Target = Documents.Add
Target.Range = Letter
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
Target.Bookmarks.Add
System.PrivateProfileString("c:\bookmarks.txt", "bookmarkNames", "bookmark"
& k), bmrange
k = k + 1
Loop
End With
Target.SaveAs FileName:="Letter" & j
Target.Close
Next j
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
If your mailmerge maindocument happens to include "#" in it, replace that
character wherever it appears in the above code with some other character
that does not appear in the document.
--
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