oilfield
01-24-2017, 03:24 AM
Hello,
I need your help. I would like to disable the close "X" button requiring the user to click on a control button that I have placed on the spreadsheet. Here is the code I have tried:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
MsgBox "Please use the button to close this file"
End Sub
The problem is this. This code works fine when the user clicks the close button the first time. If the user clicks the button a second time, the standard Save, Don't Save and Cancel window appears. How can I prevent this from happening? What needs to be changed or added to the above code?
Thank you in advance for your help!
I need your help. I would like to disable the close "X" button requiring the user to click on a control button that I have placed on the spreadsheet. Here is the code I have tried:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Cancel = True
MsgBox "Please use the button to close this file"
End Sub
The problem is this. This code works fine when the user clicks the close button the first time. If the user clicks the button a second time, the standard Save, Don't Save and Cancel window appears. How can I prevent this from happening? What needs to be changed or added to the above code?
Thank you in advance for your help!