View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Charles Kenyon
 
Posts: n/a
Default MS Word - Creat a new document for each record

If you don't get another response here, try posting in the vba.beginners
newsgroup. I didn't write the macro and I don't use it so I can't really
help you with it. I just knew that it was there and written by someone who
knows what he is doing.

Things to keep in mind, a mail merge divides records by inserting a section
break (new page), not a page break. Do you have multiple sections in your
primary merge document?
--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.


"Teeroi" wrote in message
oups.com...
Thanks - the last macro on the page does most of what I was looking
for. The only problem I'm running into is this - the macro apparently
assumes the documents is a single page, where as mine is actually 3
pages. Thus, after it reads the top line and creates the file, it
errors trying to read the top line of the next page, which is actually
part of the first document. Is there a way to programmatically assign
the number of pages per document? I've copied the macro code below.
Thanks again for you help in advance.

Sub SplitMergeLetter()
' splitter Macro modified to save individual letters with

' information from data source. The filename data must be added to

' the top of the merge letter - see web article.


Selection.EndKey Unit:=wdStory
Letters = Selection.Information(wdActiveEndSectionNumber)
Selection.HomeKey Unit:=wdStory
Counter = 1
While Counter Letters
Application.ScreenUpdating = False
With Selection

.HomeKey Unit:=wdStory
.EndKey Unit:=wdLine, Extend:=wdExtend
.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

End With
sName = Selection
Docname = "F:\Datapath\" & sName & ".doc"
ActiveDocument.Sections.First.Range.Cut
Documents.Add
With Selection
.Paste
.HomeKey Unit:=wdStory
.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
.Delete
End With
ActiveDocument.SaveAs FileName:=Docname, _
FileFormat:=wdFormatDocument
ActiveWindow.Close
Counter = Counter + 1
Application.ScreenUpdating = True
Wend

End Sub