Failed WinWord Merge in VBA Code

V

Vincent

Hello all. I am performing a merge from some VBA code using the
following code:

wordApp.ActiveDocument.MailMerge.Execute
wordApp.Documents(1).PrintOut

Sleep 5000

wordApp.Documents(1).Close wdDoNotSaveChanges
wordApp.ActiveDocument.Close wdDoNotSaveChanges
.....
If Not wordApp Is Nothing Then
wordApp.Quit
Set wordApp = Nothing
End If

When this works, it works fine. However, if the first line should
fail, I am stuck with an open WINWORD.exe in my process list. I even
make sure that all of the close() routines are called on an error.
What is causing this process to remain behind? I want to ensure this
does not happen. Thanks for your help.

-Vincent
 

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