![]() |
#5
|
||||
|
||||
![]()
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 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 Code:
Dim wdAppClass As New ThisApplication Public Sub AutoExec() Set wdAppClass.wdApp = Word.Application End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
KJJ | Word VBA | 14 | 11-10-2016 08:18 PM |
![]() |
UTSUPPORT | Word | 1 | 01-16-2012 09:27 PM |
![]() |
MikeWooZ | Excel | 6 | 12-04-2011 02:10 PM |
![]() |
caddcop | Word VBA | 3 | 06-14-2011 05:45 PM |
Disable email security prompt | mcinnes01 | Outlook | 1 | 03-17-2011 07:00 AM |