tags:

views:

1212

answers:

2

I have a macro which refreshes all fields in a document (the equivalent of doing an F9 on the fields). I'd like to fire this macro automatically when the user saves the document.

Under options I can select "update fields when document is printed", but that's not what I want. In the VBA editor I only seem to find events for the Document_Open() event, not the Document_Save() event.

Is it possible to get the macro to fire when the user saves the document?

Please note:

  1. This is Word 97. I know it is possible in later versions of Word
  2. I don't want to replace the standard Save button on the toolbar with a button to run my custom macro. Replacing the button on the toolbar applies to all documents and I only want it to affect this one document.

To understand why I need this, the document contains a "SaveDate" field and I'd like this field to update on the screen when the user clicks Save. So if you can suggest another way to achieve this, then that would be just as good.

+1  A: 

As far as I can remember of Word 97, you're fresh out of luck. The only document events in '97 were Open and Close.

I don't have Word 97 available, but in Word 2000+ you can set a field that reads a document property. You could check that out. In Word 2003 it's under Insert > Field... and the one you're looking for is called SaveDate.

Edit: D'Uh. You already knew this. Misunderstood your issue. Apologies.

fencliff
A: 

Yes, fencliff is right, you're out of luck with Word 97.

If an upgrade is not an option, the only thing that comes to my mind is polling the file's last modification time using a timer. I know it's ugly but you don't get events neither is there a Word command that you could override.

0xA3