VB app needs to wait for Word document to close
Posted on 1999-07-13
I am using VB6 and Word 97 and am launching Word from my VB app using CreateObject. I programmatically open a document for the user to view. I then want to wait for the user to close the doc before I let him continue to use my VB app, i.e. I want to suspend VB while the doc is open.
I have tried a "ping" of sorts by running a loop that gets the FullName property of the document and as long as something other than null is returned, I wait. But when the user opens a dialog in Word (e.g. Tools/Options) the OLE conversation taking place in my loop gets locked out and VB freezes so bad I have to kill it with a Ctrl-Alt-Del.
DDE is not an option from what I can tell because from past experience we know that a similar event occurs when a dialog is open, and you must communicate over channel 0 with Word temporarily until the dialog is dismissed. The LinkMode property (VB's DDE method) doesn't let you specify the DDE channel and so it will hang as well.
Is there a robust, foolproof way to wait for a Word document to close from VB?