-----Original Message-----
It's tricky. You can trap events only in a class module. So --
1. Add a class module to your macro project.
2. In the module-level declarations, add
Dim withevents mWordApp as Word.Application
3. Click the left-hand listbox at the top of the code window. You'll find
mWordApp now listed there. If you select it, the right- hand listbox will
contain the events for that object, including DocumentBeforeSave. Select
that and add your before save code.
4. In the Class module's Initialize event, add: Set mWordApp = New
Word.Application
5. In the main module of your project you need to instantiate your class
module. Any number of ways depending on what you need, but simple is to add
a module-level reference to your class module:
Dim mMyClass as new [ClassName] (whatever name you gave to the class module)
and somewhere you need to run this line:
Set mMyClass = new [ClassName] (You could put this code in an Auto macro,
or in a macro that you call explicitly when you want to start up your
system.
You also need to destroy all objects when no longer needed, using Set ... =
nothing
Asimov said:
Hi!
I try to capture the DocumentBeforeSave event in a word macro, but my code
is never reached. What's the way to capture a Word event?
Thanks,
Asimov.
.