![]() |
|
#4
|
||||
|
||||
|
Hi Tony,
Using Events requires that you instantiate the app object class. To do this, create a new class module in your mailmerge main document to register the desired Word 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_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
If Doc.MailMerge.MainDocumentType <> wdNotAMergeDocument Then
MsgBox "This is the mailmerge main document," & vbCr & _
"not the output document." & vbCr & vbCr & _
"Do not send this document to the client.", vbExclamation
End If
End Sub
Private Sub wdApp_DocumentBeforeSave(ByVal Doc As Document, SaveAsUI As Boolean, Cancel As Boolean)
Dim Rslt As Variant
If Doc.MailMerge.MainDocumentType <> wdNotAMergeDocument Then
Rslt = MsgBox("This is the mailmerge main document," & vbCr & _
"not the output document." & vbCr & vbCr & _
"Do not send this document to the client." & vbCr & vbCr & _
"Continue Saving?", vbOKCancel)
End If
If Rslt = vbCancel 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
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| hit okay to "Merge to E-mail" nothing happened | mubi_masti | Outlook | 0 | 10-21-2011 03:06 PM |
How to choose a "List" for certain "Heading" from "Modify" tool?
|
Jamal NUMAN | Word | 2 | 07-03-2011 03:11 AM |
| Can I stop the right click "move here" feature? | BillAnderson | PowerPoint | 0 | 04-16-2011 02:42 PM |
| How to stop "replace"'ing new words (in desperate need of advice) | bme081 | Word | 6 | 11-02-2009 05:57 AM |
| VBA Code for making "mailings" tab active | jandrade15 | Mail Merge | 0 | 08-01-2009 09:20 PM |