Traping save document event

J

John

Hi

I open a word document from my vb.net app. Now I need to know when the user
saves the document. How can I do that? Is there a AfterSave event exposed by
Word? If not, is there another way?

I don't mind writing macros in word as long as I am clear what I need to do.

Thanks

Regards
 
J

Jezebel

Unfortunately, there is no AfterSave event. There is a BeforeSave event; but
various circumstances can prevent the save itself from completing. One
approach is to capture the save command itself, by writing macros called
FileSave, FileSaveAs and FileSaveDefault. These will run in place of the
built-in commands.
 
J

John

Thanks.

Is there a way to pass a values from the app that opens word to the Save
macro so it can do the processing with reference to these values? Not sure
how the values are passed to word, how they stay in word until Save macro is
called and how word passes values to Save macro when it needs them.

Thanks

Regards
 
J

Jezebel

The two easy ways to attach values to a document are DocumentProperties and
DocumentVariables. DocProperties are what you see on the File > Properties
dialog. The ones you add (as opposed to the built-ins) are those listed on
the Custom tab -- these can be changed or deleted by the user, although
99.9% of users have never heard of them and don't know how. DocVariables are
similar, but can be changed only via VB/VBA; they are otherwise completely
hidden from the user.

Both DocumentProperties and DocumentVariables can also be included in the
body of the document using fields (eg for ID numbers in the footer).
 
C

Charles Kenyon

Take a look at the vba FAQ on the MVP FAQ site (below) for the page on
intercepting Word commands.
--

Charles Kenyon

See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 

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