Thread: [Solved] Message Box on Close
View Single Post
 
Old 05-10-2013, 03:54 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

You would probably do better to implement this via a DocumentBeforeClose macro, coded along the lines of:
Code:
Private Sub wdApp_DocumentBeforeClose(ByVal Doc As Document, Cancel As Boolean)
Const StrNm As String = "Home_Attempt_1_Date"
If Doc.FormFields(StrNm).Result = "N/A" Then _
  If MsgBox(StrNm & " is N/A." & vbCr & "Continue closing?", vbYesNo) = vbNo Then _
    Cancel = True
End Sub
For implementation instructions, see: http://word.mvps.org/FAQs/MacrosVBA/AppClassEvents.htm
Note also how much simpler the code can be made (even if you don't use this event)

Alternatively, see: http://word.mvps.org/faqs/macrosvba/...eforeClose.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote