Gurus needed! I'm trying to use a Word class object in order to
capture events in Word. Here's what I have, but the event code
appWord_BeforeDocumentSave... doesn't ever fire.
In a Class Module ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++
Public WithEvents appWord As Word.Application
Public WithEvents docWord As Word.Document
Public Sub appWord_DocumentBeforeSave(ByVal Doc As Word.Document,
SaveAsUI As Boolean, Cancel As Boolean)
MsgBox "This record is locked. You cannot save this file.", _
vbInformation + vbOKOnly, "Locked Record"
Cancel = True
End Sub
Public Sub OpenNewDocument(strFileName As String)
Set docWord = appWord.Documents.Open(strFileName)
End Sub
Public Sub Class_Initialize()
Set appWord = New Word.Application
appWord.Visible = True
End Sub
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++
Then in my regular code module
+++++++++++++++++++++++++++++++++++++++++++++++
Public Function OpenFile()
On Error GoTo Err_OpenFile
Dim frm As Form
Dim myWord As clsMSWord
Dim strFile As String
Set frm = Screen.ActiveForm
If frm![EventsSub].Form!FileType = "doc" Then
Set myWord = New clsMSWord
strFile = frm![EventsSub].Form.txtLinkFilePath
myWord.OpenNewDocument (strFile)
Etc....
++++++++++++++++++++++++++++++++++++++++++++++++++ ++++++++++++++++++++++++++++
This creates an instance of the class and opens Word and the file.
However, I cannot get the _BeforeDocumentSave event to work.
Am I completely delusional or should there be a way to do this?
Thanks!