>
>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)
DOEVENTS
dosomeotherstuff
ERASE
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)
if oword.documents.count < 1
"The Iron Fish: The water is cold...but the fish don't mind"
...Jay Jenks, boyhood chum