Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
Working with Windows 2000 and Word 2000
After merging a form letter, I would like to save each letter individually (i.e., letter to Mr. Smith as "Smith lettter.doc", letter to Mr. Jones as "Jones letter.doc", etc.). What's the easiest way to do this? |
#2
![]() |
|||
|
|||
![]()
There's no built-in method. In the simple case where each letter corresponds
to one record in the data source you could try adapting and running the following Word VBA macro to do one merge for each record in the data source: Sub ProduceOneDocPerSourceRec() ' NB, needs better error management and doubtless other things a VBA expert ' will point out. Dim intSourceRecord Dim objMerge As Word.MailMerge Dim strOutputDocumentName As String Dim TerminateMerge As Boolean ' Need to set up this object as the ActiveDocument changes when the ' merge is performed. Besides, it's clearer. Set objMerge = ActiveDocument.MailMerge With objMerge ' If no data source has been defined, do it here using OpenDataSource. ' But if it is already defined in the document, you should not need to define it here. ' .OpenDataSource _ ' Name:="whatever" intSourceRecord = 1 TerminateMerge = False Do Until TerminateMerge ..DataSource.ActiveRecord = intSourceRecord ' if we have gone past the end (and possibly, if there are no records) ' then the Activerecord will not be what we have just tried to set it to If .DataSource.ActiveRecord intSourceRecord Then TerminateMerge = True ' the record exists Else ' while we are looking at the correct activerecord, ' create the document path name ' e.g. something like the following, but in this case ' each lastname must be unique (and must not contain ' charters that are not allowed in a file name) strOutputDocumentName = _ "c:\mymergeletters\_" & _ ..DataSource.Datafields("lastname").Value & _ " letter.doc" ..DataSource.FirstRecord = intSourceRecord ..DataSource.LastRecord = intSourceRecord ..Destination = wdSendToPrinter 'please check the constant name ..Execute ' The Activedocument is always the output document ' Add any parameters you need to these calls ActiveDocument.SaveAs strOutputDocumentName ActiveDocument.Close intSourceRecord = intSourceRecord + 1 End If Loop End With End Sub Peter Jamieson "John Calligy" wrote in message ... Working with Windows 2000 and Word 2000 After merging a form letter, I would like to save each letter individually (i.e., letter to Mr. Smith as "Smith lettter.doc", letter to Mr. Jones as "Jones letter.doc", etc.). What's the easiest way to do this? |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How can I spellcheck the text entered into a locked form? | Microsoft Word Help | |||
form letters from word 97 to word 2003 | Microsoft Word Help | |||
Table Gridlines in Word 2003 Form | Tables | |||
Text Form Field Ref in Footer Won't Update on Screen | Microsoft Word Help | |||
Form Field Automation | Microsoft Word Help |