I created a class named clsEventHandler
In the code for the class, I entered as (General) (Declarations):
Public WithEvents EventSource As Word.Application
In the code I entered:
Private Sub EventSource_WindowSelectionChange(ByVal Sel As Selection)
If ActiveDocument.Name = "Reference List.doc" Then
.........
End If
End Sub
In the module (my main subroutine) that I attempt to run, I added at the beginning (not in Declarations), along with all my other Dimension statements:
Dim objEventHandler As clsEventHandler
My first three executable statements are:
SeeFoundRange = 1
Set mySpec = ActiveDocument
Call Create_Event_Handler
I have defined another subroutine:
Sub Create_Event_Handler()
Set objEventHandler = New clsEventHandler
Set objEventHandler.SourceEvent = Word.Application
End Sub
When I run my main subroutine it gives an error when it reaches "Set objEventHandler.SourceEvent = Word.Application"
The error is Run Time Error 348 Object does not support this property or method
Can anyone clue me in as to what might be wrong? I am running Windows XP with Word 2007. While I have written a lot of code, I have never defined my own class nor attempted to use events.