Hi all
I am attempting to detect when a word document I've opened via MS Access module was closed.
The purpose is to open document via a form (OLE), modify it, close it and refresh the OLE. it only does this with an embedded OLE object but not with a linked OLE, so I'm trying to use the close event to refresh the ole control. (plus to capture other details about the document).
I've considered that the best way to do this is through a class
In my Class module (Cls_Word):
Code:
Option Explicit
Public WithEvents DocItem As Word.Document
Private Sub DocItem_Close()
MsgBox "The document is closed."
End Sub
In my Module (Mod_Word)
Code:
Option Explicit
Public wrdEvents As Cls_Word
Sub SetDoc()
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Open(FileName:=strDocPath, ReadOnly:=False)
Set wrdEvents.DocItem = wrdDoc ' This generates a err.number: 91 err.description: Object variable not set.
End Sub
What am I missing? Or have I gone off the rails completely