I have a sub called “Autoclose” in the ThisDocument object and also, in desperation, a class module (my first “WithEvents” class) with a DocumentBeforeClose event. They both work when I open a document based on a .dot template, but neither work when I make the .dot template an addin. This is what I need because I need to intercept every time the user closes a document.
In the ThisDocument object:
Sub autoclose()
MsgBox “autoclose”
End Sub
In the class module:
Public WithEvents App As Application
Private Sub App_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
MsgBox “before close event”
End Sub
Of course with the before close event I can understand why it’s not working … because I need some way to instantiate an object variable that points to the application object and listens for events. The only place I can think of to do this is with AutoNew and AutoOpen, but just like AutoClose, these don’t fire when the template is loaded as an Addin.