Hi umesh,
Using Events requires that you instantiate the app object class. To do this, create a new class module in your document or, preferably, its template, to register your events. At the top of the module put:
Code:
Public WithEvents wdApp As Word.Application
Public WithEvents wdDoc As Word.Document
Below that, add code like the following to intercept the save event:
Code:
Private Sub wdApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
Dim Rslt As Variant
Rslt = MsgBox("Have you done your homework?", vbYesNo)
If Rslt = vbNo Then Cancel = True
End Sub
Then, in a normal code module, put:
Code:
Dim wdAppClass As New ThisApplication
Public Sub AutoExec()
Set wdAppClass.wdApp = Word.Application
End Sub
This will allow you to get events from your Word document.