Edwin Yip
Edwin Yip

Reputation: 4220

Word VBA: How to know if the actual save operation is completed?

I am having a problem with the Document.SaveAs method in Word VBA with large Word documents, it seems that the save operation is asynchronous, ie. after calling .SaveAs it returns immediately, but with large Word documents the actual save operation may not has been completed and it's in progress in another thread.

So what I want to ask is that if there is a way to detect if the actual save operation is in progress or finished?

I use Delphi to call the automation interface of Word, if it means something in discussing this problem, but I don't think so?

Upvotes: 1

Views: 2713

Answers (2)

Todd Main
Todd Main

Reputation: 29155

It's:

If ActiveDocument.Saved = True then
/* 'do something */
End If

If the document has not had a .SaveAs applied against it before, you can check this the .Path as well (i.e. If ActiveDocument.Path <> "" Then ....)

Note that it is the Background Save that is asynchronous, not the Save which you invoke manually - that is checked by .Saved.

Upvotes: 0

StevenzNPaul
StevenzNPaul

Reputation: 188

The saveas of the office automation is a out of process call, so it will always run on a seperate process, hence its asynchronous in nature.

There is literally no way to catch the notification unless it gives an exception.

Upvotes: 2

Related Questions