Hi
I have a set of macros that I need to run when the user presses the print button (stripping out superfluous text, validation etc.). Dull, but efective. I am struggling to get the event handlers to work though.
I have created my class module and declared the object variable:
Public WithEvents App As Word.Application
[Oh, I have shamelessly nicked everything from the Word VBA help file in case you haven't noticed - have dog, bark self principle]
I then proceeded to add my app_documentbeforeprint() procedure to the class module (is this the right place to put it?). All this has in it at the moment is the ubiquitous messagebox and a call to cancel the print. I am following the help file well by now, and false confidence is rising ... until I hit this:
! Where am I supposed to put this? I have put it into my macro module, to no avail, and how do I run the register_event_handler procedure?
Lost and in need of guidance!
Derren
[Mediocre talent - spread really thin]
I have a set of macros that I need to run when the user presses the print button (stripping out superfluous text, validation etc.). Dull, but efective. I am struggling to get the event handlers to work though.
I have created my class module and declared the object variable:
Public WithEvents App As Word.Application
[Oh, I have shamelessly nicked everything from the Word VBA help file in case you haven't noticed - have dog, bark self principle]
I then proceeded to add my app_documentbeforeprint() procedure to the class module (is this the right place to put it?). All this has in it at the moment is the ubiquitous messagebox and a call to cancel the print. I am following the help file well by now, and false confidence is rising ... until I hit this:
Code:
Before the procedure will run, you must connect the declared object in the class module (App in this example) with the Application object. You can do this with the following code from any module.
Dim X As New EventClassModule
Sub Register_Event_Handler()
Set X.App = Word.Application
End Sub
Run the Register_Event_Handler procedure. After the procedure is run, the App object in the class module points to the Word Application object, and the event procedures in the class module will run when the events occur.
![[ponder] [ponder] [ponder]](/data/assets/smilies/ponder.gif)
Lost and in need of guidance!
![[fish] [fish] [fish]](/data/assets/smilies/fish.gif)
[Mediocre talent - spread really thin]