Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Web & Email Web & Email
Search Search
Search for:
Tech Support Guy > > >

Run Word 97 Macro when saving document


(!)

Mike Beale's Avatar
Mike Beale Mike Beale is offline
Member with 79 posts.
THREAD STARTER
 
Join Date: Oct 1999
28-Feb-2001, 07:34 AM #1
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 !!!!)

Cheers
Mike
YSB's Avatar
YSB YSB is offline
Senior Member with 779 posts.
 
Join Date: Mar 1999
Location: New York City
05-Mar-2001, 01:36 AM #2
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!
Mike Beale's Avatar
Mike Beale Mike Beale is offline
Member with 79 posts.
THREAD STARTER
 
Join Date: Oct 1999
05-Mar-2001, 05:53 AM #3
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/of...ewEvtA2000.htm
Unfortunatly we are stuck on Office 97, D'OH!!!

Any other ideas how it would be possible?

Cheers
Mike
YSB's Avatar
YSB YSB is offline
Senior Member with 779 posts.
 
Join Date: Mar 1999
Location: New York City
06-Mar-2001, 02:53 AM #4
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!
Mike Beale's Avatar
Mike Beale Mike Beale is offline
Member with 79 posts.
THREAD STARTER
 
Join Date: Oct 1999
06-Mar-2001, 07:22 AM #5
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.

Cheers
Mike
YSB's Avatar
YSB YSB is offline
Senior Member with 779 posts.
 
Join Date: Mar 1999
Location: New York City
06-Mar-2001, 10:52 PM #6
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!



[This message has been edited by YSB (edited 03-06-2001).]
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑