VBA when saving a Word document

B

Bo Wisén

Is there any way to have my code written in VBA Word executed when I click
"Save" or "Save As" or when I try to close a document and answer Yes on the
question if I want to save the document?

Thanks
Bo
 
J

Jezebel

Write macros called "FileSave" and "FileSaveAs" -- they will run in place of
the built-in commands.
 
B

Bo Wisén

Many thanks, that works. :)

Now to my second and last problem. My macro is a form with three radio
buttons and I want Word to write one of three alternatives in the sidefoot
depending on what button I click. That's no problem. But I also want the
macro to decide if one of the alternatives already is written in the
sidefoot. Can this be done?

Thanks
Bo
 
J

Jezebel

If 'sidefoot' is a mistranslation of 'Footer', then yes. There are several
ways you could approach this.

Simplest method (to my mind): when you set up the document, add a
DocProperty field to the footer, where you want this information to appear.
Give it a default or dummy value. Then in your macro, set the value of the
document property and update fields in the footer. This way, your macro can
run as often as you like.

Another method: define the range to contain the output. Whenever the macro
runs, it replaces the content of this range with the new value.
 

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