R
richard.jolly
Dear all
I'm fairly new to class modules - but i'm ok with vba and regular
events.
I have a number of routines in modules that I want to run when the
document is changed. So far I have the following:
In Normal.dot template module
Option Explicit
Dim oAppClass As New ThisApplication
Dim strDocName As String
Dim strRefDoc As String
Public Sub AutoExec()
Set oAppClass.oApp = Word.Application
End Sub
plus....other modules below!
In Normal.dot template a Class module called ThisApplication:
Option Explicit
Public WithEvents oApp As Word.Application
Private Sub oApp_WindowActivate(ByVal Doc As Document, ByVal Wn As
Window)
ExtractDocNameRef
End Sub
ExtractDocNameRef is the name of the routine I want to run (does this
need to be in actual doc (let me call it TEST.DOC) or does it have to
be in a standard module in Normal.dot template)?
Anyhow - Auto exec fires when I boot up the Any document (really I only
want is to fire when I open TEST.DOC
Also when I change TEST.DOC the fires -good. However if I open a blank
doc, it will fire for that document.
Also once it has fired for Test doc, it will not fire again, if I make
subsequent changes.
Sorry it is a little jumbled. If it helps I can post all the routines
and try and specify what I'm trying to acheive. But for now I'm just
trying to better understand how the document change event works.
Thanks
Richard J
Nottingham UK
I'm fairly new to class modules - but i'm ok with vba and regular
events.
I have a number of routines in modules that I want to run when the
document is changed. So far I have the following:
In Normal.dot template module
Option Explicit
Dim oAppClass As New ThisApplication
Dim strDocName As String
Dim strRefDoc As String
Public Sub AutoExec()
Set oAppClass.oApp = Word.Application
End Sub
plus....other modules below!
In Normal.dot template a Class module called ThisApplication:
Option Explicit
Public WithEvents oApp As Word.Application
Private Sub oApp_WindowActivate(ByVal Doc As Document, ByVal Wn As
Window)
ExtractDocNameRef
End Sub
ExtractDocNameRef is the name of the routine I want to run (does this
need to be in actual doc (let me call it TEST.DOC) or does it have to
be in a standard module in Normal.dot template)?
Anyhow - Auto exec fires when I boot up the Any document (really I only
want is to fire when I open TEST.DOC
Also when I change TEST.DOC the fires -good. However if I open a blank
doc, it will fire for that document.
Also once it has fired for Test doc, it will not fire again, if I make
subsequent changes.
Sorry it is a little jumbled. If it helps I can post all the routines
and try and specify what I'm trying to acheive. But for now I'm just
trying to better understand how the document change event works.
Thanks
Richard J
Nottingham UK