Sheils
asked on
How to trigger codes to run each time a record mailmerge(MailMergeAfterRecordMerge)
I have some code that normally run on the document close event to register the document into a document management system. It works fine on a single document.
I now want to use it in a mail merge and run it for each record merge. The user will run the mail merge normally from the toolbar.
For each record that merges I want to pull some data from the mail merge data source and use it to register the document before merging the next record.
It seems that the MailMergeAfterRecordMerge is the event that I need to use but I don't quiet understand how to make it trigger.
I now want to use it in a mail merge and run it for each record merge. The user will run the mail merge normally from the toolbar.
For each record that merges I want to pull some data from the mail merge data source and use it to register the document before merging the next record.
It seems that the MailMergeAfterRecordMerge is the event that I need to use but I don't quiet understand how to make it trigger.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The code that I have included after your line 9 is
ThisDocument.MailMerge.Wiz ardState = 6
ThisDocument.MailMerge.Wiz
Then you will have to go the AfterProduction way
by saving the resulting Doc divided by sections
http://answers.microsoft.com/en-us/office/forum/office_2003-word/use-mail-merge-to-create-multiple-documents/a1f3c40f-36ab-4b4e-ad67-1ee09d7d84a8
Regards
by saving the resulting Doc divided by sections
http://answers.microsoft.com/en-us/office/forum/office_2003-word/use-mail-merge-to-create-multiple-documents/a1f3c40f-36ab-4b4e-ad67-1ee09d7d84a8
Regards
I've requested that this question be deleted for the following reason:
Not enough information to confirm an answer.
Not enough information to confirm an answer.
ASKER
Your code works well when merging all records from the recordsource. However it generates an error in line 39 (DocResult.SaveAs "C:\Users\Sheils\Documents
Please note that I have added a new line after your line 9 to move the mail wizard to step 6 so that the user don't have to move through the steps each time they use the mail merge.