Word COM on Close event capture
Posted: 26 Mar 2019, 07:09
I'm trying to pop up a message box when the word app is closed, but I can't seem to figure out what the event is named. If possible, I'd also like to figure out how to pop up a message box when the doc has been saved.
Code: Select all
wdApp := ComObjCreate("Word.Application") ;create a word app
wdApp.Visible := true
oConnect := ComObjConnect(wdApp,"wd_") ;connect to events
wdApp.Documents.Add() ;add a new document
wd_NewDocument(Doc,App) { ;when creating a new document, this triggers
MsgBox, % Doc.Name ; Show the name of the new document
App.Selection.TypeText("Hello world") ; Type text at the current selection
}
wd_Close(Doc,App) ;<------------ Here is the problem, I've tried wd_Close,wd_Quit and wd_Exit with no success
MsgBox, % App.Name ; Show the name of the application
ComObjConnect(App) ; Disconnect from App events
}