andydtaylor
Active Member
- Joined
- Feb 15, 2007
- Messages
- 360
- Office Version
- 2016
Hi,
I'm looking for help implementing a worksheet_beforesave macro. If I run exactly what is written at the MS Excel help page below, my workbook saves even if the user clicks "No" to "Do you really want to save the workbook?". Has anyone seen this effect before and have an idea how this behavior can be corrected?
Workbook.BeforeSave event (Excel)
I've seen this behaviour as I come back to this workbook over the last few weeks so it's not a one-time effect. I'm using Office Professional Plus 2016. I appreciate your help!
My objective is to prevent a user from pressing ctrl-s to save a workbook without a filename check being run. I have already implemented this check as part of a collection of power query queries so the final check will reduce down to the following, albeit perhaps with a sheet reference:
If Range("o_val[Cross-Check]").Value = "Problem Detected" Then
In debugging this I realised that even the MS stock example fails, hence the focus of this post. For context in case there is another way to implement my goal.
Regards,
Andrew
I'm looking for help implementing a worksheet_beforesave macro. If I run exactly what is written at the MS Excel help page below, my workbook saves even if the user clicks "No" to "Do you really want to save the workbook?". Has anyone seen this effect before and have an idea how this behavior can be corrected?
VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, _
Cancel As Boolean)
a = MsgBox("Do you really want to save the workbook?", vbYesNo)
If a = vbNo Then Cancel = True
End Sub
Workbook.BeforeSave event (Excel)
I've seen this behaviour as I come back to this workbook over the last few weeks so it's not a one-time effect. I'm using Office Professional Plus 2016. I appreciate your help!
My objective is to prevent a user from pressing ctrl-s to save a workbook without a filename check being run. I have already implemented this check as part of a collection of power query queries so the final check will reduce down to the following, albeit perhaps with a sheet reference:
If Range("o_val[Cross-Check]").Value = "Problem Detected" Then
In debugging this I realised that even the MS stock example fails, hence the focus of this post. For context in case there is another way to implement my goal.
Regards,
Andrew
Last edited: