Is it Word or your application that is locked?
You might want to give Word a few seconds to save the document before closing it.
Printable View
Is it Word or your application that is locked?
You might want to give Word a few seconds to save the document before closing it.
Hi Joacim,
According to the Task Manager it's VB that's stuck - but my VB program will finish no problem.
Even if I break the program mid way - and manually switch to Word, I can open and close files - but as soon as I try to Quit/Exit word hangs.
If I open and close word without manipulating any files there is no problem but I'm doing the following;
I am opening a prototype word file, performing a find and replace on certain bits of text, copying the whole document and pasting it into another document. (Doing that multiple times)
I must be doing something stupid with the find and replace to cause Word to hang - I'll just have to go through the code bit by bit.
If I execute the code WordApp.Quit it hangs.
Or if I remove that code and leave Word active after my VB program has finifhed - and maually try to exit it hangs?
Cheers,
Graham.
Its my guess that the reason its hanging is that C:\temp.doc already exists. In word (or most windows apps) if you try and save to a path that already exists you are prompted for confirmation before it will save.
When you try and save in Word when you have made no modification, the save is effectively ignored (I think) so this is why it works when no modifications are made.
For anybody who is interested I figured out what I was doing wrong (or not doing right)..
I was doing a lot of copying and pasting...
..and like a lot of Windows apps - the app will ask if you if you want to save the contents of the clipboard before existing etc..
If you perform an app.quit command (WordApp.Quit in this case), it will default 'Yes' to the request to save the clipboard info.
Anyway - I had so much info on the clipboard that Word got stuck trying to save the clipboard (probably would have cleared itself eventually - but it was taking forever).
I just put a Clipboard.Clear (thanks to noone & megatron)at the right point prior to quitting Word.
Graham.