i currently use a macro that outputs each record of a merged document as a text file, but what we do is add the word "end "
to the last entry in the excel data source
the word macro loops through each record until it sees the word "end" then stops! but with an error ,well that ok but its messy, how can i change it so that once the last record is found it stops!(a message box with "20 generated" or similar would be nice!
here's the code.
Sub Createtext()
Do
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
'Click the button to select the next record if in manual mode
a1 = ActiveDocument.Words(2).Text
a2 = ActiveDocument.Words(3).Text
a3 = ActiveDocument.Words(4).Text
a4 = ActiveDocument.Words(5).Text
a5 = ActiveDocument.Words(6).Text
a6 = ActiveDocument.Words(7).Text
a7 = ActiveDocument.Words(8).Text
'Select the second word of document as reconstructed filename
ActiveDocument.SaveAs FileName:=a1 + a2 + a3 + a4 + a5 + a6 + a7 + ".txt", FileFormat:=wdFormatDOSText
'Save the text file
Loop Until a1 = "end" ' The last record must contain "end"
End Sub
Bookmarks