G
Greg Lovern
If I set Cancel = True in the BeforeSave event:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True '(to save this change, I set a breakpoint on this
line to skip it; then removed the breakpoint)
End Sub
And then make any change to the workbook, and close the workbook, and
click Yes when prompted whether to save the changes, it prompts me
again whether to save the workbook. As long as I continue clicking
Yes, it continues prompting me in an infinite loop.
Why does Excel continue to prompt? I cancelled the save; shouldn't
Excel just close it without saving?
If the user clicks Yes in that situation, what can I do to stop Excel
from prompting again? An inelegant workaround is to SendKeys a Cancel
key to the prompt dialog, like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
SendKeys "Cancel"
Cancel = True
End Sub
But then I'm sending that Cancel key under all Save circumstances. I
could set a flag in BeforeClose and only SendKeys the Cancel key when
that flag is set. But I'd rather do it without SendKeys if possible.
Any ideas?
Thanks,
Greg
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
Cancel = True '(to save this change, I set a breakpoint on this
line to skip it; then removed the breakpoint)
End Sub
And then make any change to the workbook, and close the workbook, and
click Yes when prompted whether to save the changes, it prompts me
again whether to save the workbook. As long as I continue clicking
Yes, it continues prompting me in an infinite loop.
Why does Excel continue to prompt? I cancelled the save; shouldn't
Excel just close it without saving?
If the user clicks Yes in that situation, what can I do to stop Excel
from prompting again? An inelegant workaround is to SendKeys a Cancel
key to the prompt dialog, like this:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)
SendKeys "Cancel"
Cancel = True
End Sub
But then I'm sending that Cancel key under all Save circumstances. I
could set a flag in BeforeClose and only SendKeys the Cancel key when
that flag is set. But I'd rather do it without SendKeys if possible.
Any ideas?
Thanks,
Greg