How to make my vb application wait until MS-WORD completes saving the active document?

M

mlsrinivas

Hi,

How to make my vb application wait until MS-WORD completes saving the
active document?

Ours is transcription company and I develop softwares for daily use.
The work flow application I developed is in VB 6.0.

Ms-Word automation is used to interact w/ Word from VB application.
When I use
'wordapp.activedocument.save' from VB sometimes the next line of code
is getting executed before MS-Word completes saving the document. I
used 'DoEvents' w/o much success.

I open word documents on a network drive from VB, process them,save and
close, and rename them.

Sometimes they do not get renamed as the saving is not completed and
sometimes they do not get saved.

Hence I want my application to wait until Word completes saving the
documents.

Any clues?

Thanks

Srinivas
 
J

Jonathan West

Hi Srinivas

Two possibilities

1. You can set the Options.BackgroundSave property of Word to false before
saving. Then the next line of code should not execute until the save is
complete. Restore it to the original value afterwards.

2. You can query the BackgroundSavingStatus property. That returns an
integer vale indicting he number of documents in the process of being saved
at the moment. When the number drops to zero, you know the save has been
completed.

Of the two, I would favor option #1 if you are operating a batch process.
Much cleaner to code it that way.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
M

mlsrinivas

Jonathan,

Option #1 worked fine for some documents, but still I have some
documents for which my application is not waiting until the Word's save
process is completed.

Please help

Thanks

Srinivas
 
J

Jonathan West

Jonathan,

Option #1 worked fine for some documents, but still I have some
documents for which my application is not waiting until the Word's save
process is completed.

Please help

I'll need to see the relevant code. Also, is there any distinguishing
feature of the documents where the application doesn't wait, or some other
distinguishing circumstance that you can identify. Just saying there are
"some documents for which my application is not waiting" doesn't give me
much to go on.


--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top