Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Merge Help Please 1

Status
Not open for further replies.

daylilies

Technical User
Dec 13, 2001
8
US
I am working in word merge and we are creating letters for over 200 individuals. These letters then need to be saved as a seperate file for each individual. Does anybody know how I can do this without having to merge each selected record seperately. I will have to do this often and will need to do it as fast as possible. Any help would be appreciated. Thank You, Erica
 
This macro assumes that the data source is in a Word table, which is the default option when creating data. Currently it saves the letters as "Letter 1.doc", "Letter 2.doc" etc, so it could use some adjustment here to make the naming convention a little more friendly. It's also designed to be run with the main document of the screen open and active in Word.

Sub MergeIndividual()
Dim strPath As String
Dim intCount As Integer
Dim i As Integer


strPath = ActiveDocument.Path
ActiveDocument.MailMerge.EditDataSource

intCount = ActiveDocument.Tables(1).Rows.Count

ActiveDocument.MailMerge.EditMainDocument

For i = 1 To intCount - 1
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True

With .DataSource
.FirstRecord = i
.LastRecord = i
End With

.Execute Pause:=True
End With

ActiveDocument.SaveAs strPath & "\Letter " & i & ".doc"
ActiveWindow.Close
Next i
End Sub
 
Thank You so much. This was the perfect solution!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top