Rich was telling us:
Rich nous racontait que :
Here are the other two modules:
Public Sub Class_Initialize()
Set app = Application
End Sub
================
Sub Register_Event_Handler()
Set Action1 = Word.Application
End Sub
What is Action1? I do not see it declared anywhere.
What kind of modules are these?
What is the name of the Class module?
Did you actually read the web page I recommended?
I think you should... I could give you the code you need, but because
application events can be confusing, I think it is important that you
understand what is going on. The page I recommended is very well written and
if you follow the instructions one strep at the time, you will get what you
want in no time at all. Especially if you are coming from Excel where all
the work has been done under the hood.... In Word you have to create the
whole code for the event from scratch.
Just two comments regarding the web page.
1)
In step 4 and 5, it is assumed that you are producing a global template.
While that makes sense for application wide events, that may not be the case
( I have had to use Application wide events that applied only to a sub-set
of documents based on a few templates).
Anyway, if the template is not going to be used as a global one, then the
first thing you have to do is change the AutoExec macro to one macro (Or two
macros if you are using a template):
'_______________________________________
Private Sub Document_Open()
Set oAppClass.oApp = Word.Application
End Sub
'_______________________________________
and possibly:
'_______________________________________
Private Sub Document_New()
Set oAppClass.oApp = Word.Application
End Sub
'_______________________________________
This way, the class module will be initialize when a document is opened or
created form the template, even if it is not in the start-up folder.
If you are not creating a global template, you have to be aware of the fact
that whatever code you write will be activated for all documents after
initializing the class module. You may want to add code to make sure that
the code only executes for the documents you want.
2)
In step 6, select the BeforeSave event and write your code there.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org