MailMergeAfterMerge event

D

Danny

Hi all,

I am developing a c# console application that takes data from a database and
doing a mail merge in word 2003 to create a contract. I added an event
handler for the MailMergeAfterMerge event:

_WordApp.MailMergeAfterMerge += new
Word.ApplicationEvents4_MailMergeAfterMergeEventHandler(wrdApp_MailMergeAfterMerge);

In the event handler I save the doc and am doing a Console.WriteLine to see
when it is firing so I can debug it:


result.SaveAs(ref _oContractPath, ref _oMissing, ref _oMissing, ref
_oMissing, ref _oMissing, ref _oMissing,
ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing, ref _oMissing,
ref _oMissing, ref _oMissing, ref _oMissing,
ref _oMissing, ref _oMissing);

Console.WriteLine(_oContractPath.ToString() + " Saved.");


The issue I am having is that this event does not fire all the time. It is
really inconsistent. Right now I am testing with 11 contracts. The first
time I run the application one of the contracts does not get saved. The next
time all will be ok. Then the next time I run it 4 contracts did not save.
I don't know why the inconsistency but it is really bugging me. Does anyone
have any ideas why it works only sometimes? Please Help!!

Thank you in advance.

Danny
 
B

blaine

Danny,

I have been battling with this problem for quite some time.

I have written a mail merge component in VB and have experienced this
glitch with word 2003 a great deal. I have also experienced mail merges
that have executed correctly but I've also received an error from the
..Execute method at the same time...!?

I've narrowed the problem down to the fact that word is temperamental
when mail merging if word is invisible at the time of the mail merge!!
I've resolved this by setting up my merge template and data source with
word invisible then setting the application window state to minimised
(to prevent me from getting sued by someone with epilepsy), then
visible and then execute the mailmerge.

In the MailMergeAfterMerge event, I close the template and maximise the
resulting mailmerged document.

This is really hard to test and verify 100% as it's so random, but I've
not had the issue again since I made this change.

Please let me know if this resolves your problem.

Regards,

Blaine
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top