1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Run Word 97 Macro when saving document

Discussion in 'Web & Email' started by Mike Beale, Feb 28, 2001.

Thread Status:
Not open for further replies.
Advertisement
  1. Mike Beale

    Mike Beale Thread Starter

    Joined:
    Oct 27, 1999
    Messages:
    79
    I know this must be simple, but I just can't figure it out at the moment!
    I've got a macro in Word 97, written in VBA, and I want it to run when the document is saved (when user selects File/Save or File/SaveAs)

    I'm sure i've seen it done (I might have even done it myself in the past in Word 6 [​IMG] !!!!)

    Cheers
    Mike
     
  2. YSB

    YSB

    Joined:
    Mar 7, 1999
    Messages:
    779
    The Word.Application object has an event called DocumentBeforeSave that sounds like what you are looking for. In order to access this event you have to create an event handler for the Application object. If you need more help in doing that, let me know. You should also find more details in the Word help files about that event and handling it.

    Let us know what happens. Good Luck! [​IMG]
     
  3. Mike Beale

    Mike Beale Thread Starter

    Joined:
    Oct 27, 1999
    Messages:
    79
    YSB.
    Thanks for your reply.
    I started to look in Word and the help for more info, and eventually on MSDN, but unfortunatly it looks as if the DocumentBeforeSave is a new event added in Office 2000 http://msdn.microsoft.com/library/officedev/off2000/womscNewEvtA2000.htm
    Unfortunatly we are stuck on Office 97, D'OH!!!

    Any other ideas how it would be possible?

    Cheers
    Mike
     
  4. YSB

    YSB

    Joined:
    Mar 7, 1999
    Messages:
    779
    Thanks for that info. I guess it doesn't do you any good though.

    If you want a macro to run some event has to trigger it. To be honest, I found the DocumentBeforeSave event by searching the Object Browser for the word Save. I don't have Word97 so I wouldn't be able to do the same thing for Word97 objects. I'm really not sure what else it might be as I really didn't see anything else that would do it in the Document or Application objects. All I could say is to search through the Object Browser for some other event that might be triggered during a save. If I have a chance I'll take another look and see if I come up with anything else.

    Actually here is a thought that just crossed my mind. Could you replace the Save menu item with a macro by customizing the toolbar?

    Let us know what happens. Good Luck! [​IMG]
     
  5. Mike Beale

    Mike Beale Thread Starter

    Joined:
    Oct 27, 1999
    Messages:
    79
    YSB.

    Great, thanks, why didn't I think of that!!
    Replacing the Save menu/toolbar buttons with my macro has done the trick.

    Thanks again. [​IMG]

    Cheers
    Mike
     
  6. YSB

    YSB

    Joined:
    Mar 7, 1999
    Messages:
    779
    Don't feel bad. I didn't think of it either until I was almost finished typing that last post. The obvious answer is usually the most elusive! [​IMG]



    [This message has been edited by YSB (edited 03-06-2001).]
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/39256