Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make sure Word is gone
Message
 
 
To
27/11/2000 17:02:21
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00443950
Message ID:
00446101
Views:
9
>So now I have
>
>
omydoc.close(wdSaveChanges)  &&close and save mytempfile
>DOEVENTS            && let it finish closing
>if oword.documents.count < 1
>   oword.quit()
>   DOEVENTS         && let it finish quitting
>endif
><stuff>
>ERASE mytempfile
>
>This seems to work, but I don't really feel like I have positive control of the race condition; I've just separated the act of closing the document from the act of quitting word. This seems to give my code the time it needs before it issues the erase ... but seemingly as a side-effect rather than as a result of direct control.
>
>Any other insight on how to make sure Word has released mytempfile before I try to erase it?

That act of separating the closing of the document from the quitting of Word may be what's needed. By asking Word to close the file first, THEN shut itself down, it ensures that the file is shut down and released, before moving along to shutting itself down. Perhaps it changes a little timing with the OS, ensuring that the process of flushing/releasing the lock on the file happens a little sooner when issuing Close, then the Quit method can work while (or won't start until?) the OS finalizes its thing. This is purely conjecture on my part, based on the fact that I can always get the code to fail without Closing the document, and it always works when the document is Closed first -- and the Winword.EXE task in the task manager disappears from the list a split second after the error appears, without any other user input.

Maybe somebody who knows more about how the OS works with files can comment?

- della
Previous
Reply
Map
View

Click here to load this message in the networking platform