Automated instance of word waits for answer to question it never asks!
I've created a program that uses automation through late-binding to word to open, edit and 'save as' documents. This is all done without the normal word user interface.
Most of the time this works fine, but occasionally, word crashes while attempting to open the template document. My program then stalls, waiting for word to return, which it never does.
I create the word object with the following code
Code:
If wdApp Is Nothing Then
Set wdApp = CreateObject("Word.Application")
Else
Set wdApp = GetObject(, "Word.Application")
End If
I open the template doc with
Code:
wdApp.documents.Open Config.AppPath & MasterBlankDoc
MasterBlankDoc is a string containing the filename of the template document.
Is there a way to enable my program to continue execution after calling the open instruction without waiting for wdApp to return control? And if so, is there a way to determine the state of word so my program can tell if it has crashed or not?
Just to be really annoying, when word does crash, it leaves a file lock in memory on the template document, so when I re-run my program, as soon as it tries to open the doc again, word brings up a dialog box saying the doc is already open and can only be opened in read-only mode. However, this dialog box is always hidden in the background. The only way to get to it is to alt-tab, which is fine if you know about this, but to those users who don't, it just looks like the program has frozen up again!
Any help or suggestions would be appreciated as this problem has been bugging me for months!
Oh, for those who are interested, the program is used in a school to write and print student reports.
Thanks.
Ludwig.