Thread: [Solved] Message Box on Close
View Single Post
 
Old 05-10-2013, 08:28 AM
thedeadzeds thedeadzeds is offline Windows XP Office 2003
Novice
 
Join Date: May 2013
Posts: 5
thedeadzeds is on a distinguished road
Default Message Box on Close

Hi All,

I have the following code which works great. However, I want to adapt it so if the message box is clicked 'No' Then the document DOES NOT close. Is this possible?

Thanks
Code:
Private Sub Document_Close()
Dim orng As Word.Range
Dim ofld As FormFields
Set orng = ActiveDocument.Range
Set ofld = orng.FormFields
For i = 1 To ofld.Count
  ofld(i).Select
  If ofld(i).Name = "Home_Attempt_1_Date" Then
    If ofld(i).Result = "N/A" Then
      MsgBox ofld(i).Name & " is N/A, ", vbYesNoCancel
      Exit Sub
    End If
  End If
Next i
ActiveDocument.Close
End Sub
Reply With Quote