T
TheMarioInc
Hello,
I have created a one page "checklist" consisting of a few tables for a
user to enter information, as well as four checkboxes from the Control
Toolbar. I have my own FileSave and FileSaveAs macros to force the
user into entering some information prior to saving the document.
I also used Document_Close to bypass the generic "Do you want to save
changes..." prompt. If ThisDocument.Saved is false my Yes/No/Cancel
box appears.
Yes - call my FileSave macro
No - set ThisDocument.Saved to True (to bypass the built-in "Do you
want to save changes..." prompt and exit)
Cancel - send Esc
All of this worked well until I added the checkboxes. If the user
makes a change to a table cell (e.g. they enter their name), and tries
to close the document without saving, my prompt appears. If they
click No, the document closes (no further questions asked). If they
click one of the checkboxes and try to close the document, my prompt
appears. After clicking No, the built-in "Do you want to save
changes..." appears even if ThisDocument.Saved is set to True by the
prior "No" click. How do I prevent a change to the checkbox from
causing Word to prompt the user to save with its own dialog box?
Private Sub CheckBox1_Click()
ThisDocument.Saved = False
End Sub
Private Sub Document_Close()
...
' Present the user with custom options if an attempt is made to
close the
' document without saving
If Not ThisDocument.Saved Then
intMsgBoxResult = MsgBox(strFileName & " has changed. Save the
change(s)?", _
vbYesNoCancel + vbQuestion,
"Checklist")
If intMsgBoxResult = 6 Then 'Yes
' Ensure that if the user choses to save the document that
the Name field is populated
If strName = "" Then
intMsgBoxResult = MsgBox("Please enter a Name prior" _
& " to saving the document.",
vbCritical, _
"Checklist")
SendKeys "{ESC}"
ThisDocument.Bookmarks("YourName").Select
Else
Functions.FileSave
End If
ElseIf intMsgBoxResult = 7 Then 'No
' Prevent Word's default "save changes" prompt from
activating
ThisDocument.Saved = True
ElseIf intMsgBoxResult = 2 Then 'Cancel
' Word's default "save changes" prompt will become
activated, but
' close immediately
SendKeys "{ESC}"
End If
End If
End Sub
Thanks,
Mike
I have created a one page "checklist" consisting of a few tables for a
user to enter information, as well as four checkboxes from the Control
Toolbar. I have my own FileSave and FileSaveAs macros to force the
user into entering some information prior to saving the document.
I also used Document_Close to bypass the generic "Do you want to save
changes..." prompt. If ThisDocument.Saved is false my Yes/No/Cancel
box appears.
Yes - call my FileSave macro
No - set ThisDocument.Saved to True (to bypass the built-in "Do you
want to save changes..." prompt and exit)
Cancel - send Esc
All of this worked well until I added the checkboxes. If the user
makes a change to a table cell (e.g. they enter their name), and tries
to close the document without saving, my prompt appears. If they
click No, the document closes (no further questions asked). If they
click one of the checkboxes and try to close the document, my prompt
appears. After clicking No, the built-in "Do you want to save
changes..." appears even if ThisDocument.Saved is set to True by the
prior "No" click. How do I prevent a change to the checkbox from
causing Word to prompt the user to save with its own dialog box?
Private Sub CheckBox1_Click()
ThisDocument.Saved = False
End Sub
Private Sub Document_Close()
...
' Present the user with custom options if an attempt is made to
close the
' document without saving
If Not ThisDocument.Saved Then
intMsgBoxResult = MsgBox(strFileName & " has changed. Save the
change(s)?", _
vbYesNoCancel + vbQuestion,
"Checklist")
If intMsgBoxResult = 6 Then 'Yes
' Ensure that if the user choses to save the document that
the Name field is populated
If strName = "" Then
intMsgBoxResult = MsgBox("Please enter a Name prior" _
& " to saving the document.",
vbCritical, _
"Checklist")
SendKeys "{ESC}"
ThisDocument.Bookmarks("YourName").Select
Else
Functions.FileSave
End If
ElseIf intMsgBoxResult = 7 Then 'No
' Prevent Word's default "save changes" prompt from
activating
ThisDocument.Saved = True
ElseIf intMsgBoxResult = 2 Then 'Cancel
' Word's default "save changes" prompt will become
activated, but
' close immediately
SendKeys "{ESC}"
End If
End If
End Sub
Thanks,
Mike