Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to make sure Word is gone
Message
 
À
27/11/2000 17:02:21
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00443950
Message ID:
00446101
Vues:
14
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform