View Single Post
 
Old 11-24-2015, 05:29 AM
gmaxey gmaxey is offline Windows 7 32bit Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

You are going to need to create a template addin containing an event handler.

'Put this code in a standard code module:
Public AppEvents As New clsEvents
Public Sub AutoExec()
Set AppEvents.WordApp = Word.Application
End Sub
'Put this code in a class module named clsEvents:
Public WithEvents WordApp As Word.Application
Private Sub WordApp_DocumentOpen(ByVal strDocName As Word.Document)
MsgBox strDocName & " is opening"
End Sub
Private Sub WordApp_DocumentBeforeClose(ByVal strDocName As Word.Document, ByRef Cancel As Boolean)
MsgBox strDocName & " is closing"
End Sub
Private Sub WordApp_Quit()
MsgBox "WordApp_Quit"
End Sub

You can probably put your code in the DocumentBeforeClose event.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote