How to forcibly kill the word session?

V

Veena

Hi,
We have a VB program which opens word documents and data source and
performs mailmerge programmatically.
Whenever there is a problem with mailmerge (eg: some mergefields are
missing) the word session hangs.
Can you please tell me a method wherein i can forcible kill the word
session. I tried calling the Quit method on WordApplication object and
close method on the word docs which are open. Both the statements hang
as word itself has hanged.
How do i forcible kill the word session programmatically ....
Any help would be greatly appreciated.

Thanks & Regards,
Veena.
 
G

Graham Mayor

If you can find a way to forcibly kill Word using vba that is also hung, and
then manage to deal with all the problems created by orphaned temporary
files that crashing Word will leave behind and the possibility that
autorecover may or may not be active on the target machine, then that would
be a nifty piece of programming.

I would have thought a better approach would have been to error trap the
problems that are likely to occur so that it doesn't hang in the first
place. I suggest posting the errant part of the code in one of the vba
newsgroups with a request for how best to error trap that aspect of it.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
V

Veena

Thank you for the suggestion Graham !!!
But, actually we are trying to cater to the generic scenario when word
hangs.
In a normal scenario ,after doing a mailmerge (programmatically), the
merged output document is produced and the subsequent mail merges go
through fine.
But, in some cases, the mail merge fails, eg,it pop-ups some dialogs,
like "Record and header delimiter" or "invalid merge field". These
dialogs require manual intervention but, programmatically it is
difficult to supress these dialogs, the reason being there are
multiple scenarios or worse still the WORD session itself is hidden.
Thus, i need a generic solution wherein, if the word hangs or is in a
inconsistent state, i can forcibly kill it, open a fresh session again
and continue the mailmerges.

Please advice!!
Thanks & Regards,
Veena.
 
G

Graham Mayor

Take a look at vba help for 'On Error Statement' which should cover your
requirements.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 

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