Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wait While MSWord has not Finished Processing ?

Status
Not open for further replies.

Lemox

Programmer
Dec 13, 2003
67
GB
Hi,

I would like to pause my application while a word process hasn't finished working... I produce a Word Document that should be saved automatically.

With these lines :
Code:
Wordapp.Visible = True
Wordapp.ActiveDocument.Save

My application seems to have finished its work and I can see that Word is still trying to do sthg (don't know what : I suppressed Grammar and Spelling Checks)
When I try to close the document, Word asks for saving changes. I don't want that...

So how can I know from my vb application when WORD has REALLY finished doing his mysterious stuff ??
Is there a kind of Status that could be checked ?

I put a kind of 'sleep' for 1 minute before 'Wordapp.ActiveDocument.Save'... it works :
Word no longer asks for saving.
But this is far from being clean..

Thanks in advance !
Lemox
 
Well you could do a check.

If Wordapp.ActiveDocument.Saved = True Then

However, I am not sure how you would handle things if it comes back False. Do a pause? Check every 5 seconds?

Gerry
 
Any resolution to this, I also need help in pausing my app for a Word process to finish (just a couple of seconds).
 
Go to Word help and look up the Save method. There are 500000 optional parameters including one to ignore the prompt to save option.

Secondly, if your application is continuing while word is completing an instruction then look for a way to avoid this in the Word API. For example when printing, you can tell word NOT to use background printing.

If there is no way to avoid a pause, then try to avoid any form of loop. Have a timer on a form or look in these forums for the WaitOnObject API usage.

When I had to write code that printed a word document to a file, I did it using VB with 2 separate apps running which communicated via pipes. I would only go that path if you really have to and in my experience (because I did not have to save files) everything that I told word to do finished properly before my next line of code ran.
 
Thank you for the advice PCLewis. I am working on a vb.net app that involved Word. I am toying with the filesystemwatcher class to help with output from word. It's interesting to say the least.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top