Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
roudoudouze
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson
 
Posts: n/a
Default 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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
NO CODE - mail merge to Outlook with attachment with CC BrianH Mailmerge 1 February 10th 10 02:53 PM
Mail Merge Help Needed. Filters will not work. I am DESPERATE Dee Carpenter Mailmerge 1 January 9th 06 04:07 PM
Mail Merge Losing Data Scott May Mailmerge 1 November 1st 05 11:03 PM
Automate a mail merge in Word 2002 from a macro in Access 2002 Ed B Mailmerge 9 July 8th 05 04:31 PM
mail merge with attachments AS Mailmerge 5 April 9th 05 09:49 AM


All times are GMT +1. The time now is 10:44 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"