Results 1 to 1 of 1
Thread: Word Application Events - Tip
2001-04-05, 17:56 #1
- Join Date
- Dec 2000
- Hollywood (sorta), California, USA
- Thanked 0 Times in 0 Posts
Word Application Events - Tip
Had trouble getting Applications Events to work correctly? Staying up all hours wondering why you can't get these events to function? (See Dave Rado's article:
<A target="_blank" HREF=http://www.mvps.org/word/FAQs/MacrosVBA/AppClassEvents.htm>http://www.mvps.org/word/FAQs/Macros...lassEvents.htm</A> for a description and setup instructions.)
Here's a troubleshooting tip I've discovered when trying to set up application events in Word. I'm still in Word 97, but this applies to 2000 as well (you just get more built-in events with 2000). After setting up App events, I could not understand why project UI ignored the code in the document_open and close events.
TIP: Code the class initialize and class terminate events with a msgbox then watch to see when these events fire as you use your project.
I discovered the class was terminating at the end of my AutoExec sub. My code entry point for the UI is NOT the autoexec. The AutoExec only sets up the Word session. The UI entry point is another sub. So I moved the instantiate statement:
Set oAppClass.oApp = Word.Application
to the UI entry point sub and viola! The class remains throughout the session and works as expected. In other words, instantiate the app events class in a sub that stays open throughout your "macro session". Closing the sub that instantiates the class terminates the class!Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
<img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>