Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make sure Word is gone
Message
From
27/11/2000 17:02:21
 
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00443950
Message ID:
00445876
Views:
12
>
>Try adding a DOEVENTS after quit, and another after the copy. I think VFP simply fires off each line and doesn't wait for Windows events to process before proceeding. DOEVENTS will likely solve that.

Well, the DOEVENTS looked hopeful, but does not seem to do the trick. I placed a DOEVENTS right after the QUIT and I still get a 'file access denied' when I subsequently try to erase the document I was working on.

The errant code has the following form
oword.quit(wdSaveChanges)   &&save mytempfile then close word
DOEVENTS
dosomeotherstuff
ERASE mytempfile
If I break on the quit line, then continue, I get the 'file access denied' error.

If I break on the DOEVENTS line (or any other line before the erase), the ERASE succeeds.

However, I was able to make things work the way I want them to by issueing a document.close prior to quitting (had to do this anyway due to suggestions in my other thread 'How to make sure word is gone'). 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?
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform