Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Help needed to automate Mail-Merge
My program uses COM to automate a mail-merge process.
When the mail-merge is complete, the Documents collection of the Application contains three or four documents : the template, the datasource, the mail-merge output and, if applicable, the mail-merge error report. Is there a way to differentiate these documents, i.e. how to identify which one is the mail-merge output ? At the moment, I'm using the document name, but this does not work when running my program with non-english MS-Office |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Help needed to automate Mail-Merge
I don't have code for this, but I think what you need to do to cope with all
possible outcomes is a. iterate through the Documents collection before the merge and save the document names. Let's suppose there are n names b. set a reference to the Mail Merge Main Document before you merge c. after the merge, there will be n documents, n+1 documents or n+2 documents. d. the reference you set will still be to the Mail Merge Main Document e. If you have n+1 documents and you were merging to a new document, there is no Error Document and the ActiveDocument post-merge will be the output document f. if you have n+1 documents post-merge and you were not merging to a new document (/and/ you used the Pause:=False parameter in the MailMerge.Execute method, then the ActiveDocument post-merge will be the error document g. if you have n+2 documents post-merge then the ActveDocument will be the Error document, and (as far as I know) nothing references the output document. It may be that you can rely on looking at the [n+1]th or [n+2] member of the Documents collection to get a reference to the Output Document, but I would personally tend to iterate through the Documents collection looking for the document with a name that was not one of the n names pre-merge, and where the name is not the same as the name of ActiveDocument (i.e. the error document). I will probably do some code for this soon but don't hold your breath. Peter Jamieson "roudoudouze" wrote in message ups.com... My program uses COM to automate a mail-merge process. When the mail-merge is complete, the Documents collection of the Application contains three or four documents : the template, the datasource, the mail-merge output and, if applicable, the mail-merge error report. Is there a way to differentiate these documents, i.e. how to identify which one is the mail-merge output ? At the moment, I'm using the document name, but this does not work when running my program with non-english MS-Office |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
NO CODE - mail merge to Outlook with attachment with CC | Mailmerge | |||
Mail Merge Help Needed. Filters will not work. I am DESPERATE | Mailmerge | |||
Mail Merge Losing Data | Mailmerge | |||
Automate a mail merge in Word 2002 from a macro in Access 2002 | Mailmerge | |||
mail merge with attachments | Mailmerge |