A
Alan McQuaid via OfficeKB.com
Hello,
I am trying to use the beforeclose event on a workbook. However, it appears
to be getting bypassed everytime I close the book as I am being asked the
standard "Do you want to save the changes to...". Here is what I have written
for it.
Private Sub workbook_beforeclose(Cancel As Boolean)
Cancel = False
If Sheets("Check").Range("Protected") = "Y" Then
If bBlockEvents Then Exit Sub
ThisWorkbook.Saved = True
bBlockEvents = True
Else
If Range("Prepare") > "" And Range("Checked") > "" And Not Range
("Protected") = "Y" Then
Message = MsgBox("Is this workbook finished with for today?",
vbYesNo + vbCritical)
If Message = vbNo Then
Call DeleteEVMenu 'Sub to delete custom menu
Else
Sheets("Check").Range("Protected") = "Y"
ProtectSheets 'Sub to protect certain sheets
Call DeleteEVMenu 'Sub to delete custom menu
ThisWorkbook.Save
End If
End If
End If
End Sub
Any help would be much appreciated
I am trying to use the beforeclose event on a workbook. However, it appears
to be getting bypassed everytime I close the book as I am being asked the
standard "Do you want to save the changes to...". Here is what I have written
for it.
Private Sub workbook_beforeclose(Cancel As Boolean)
Cancel = False
If Sheets("Check").Range("Protected") = "Y" Then
If bBlockEvents Then Exit Sub
ThisWorkbook.Saved = True
bBlockEvents = True
Else
If Range("Prepare") > "" And Range("Checked") > "" And Not Range
("Protected") = "Y" Then
Message = MsgBox("Is this workbook finished with for today?",
vbYesNo + vbCritical)
If Message = vbNo Then
Call DeleteEVMenu 'Sub to delete custom menu
Else
Sheets("Check").Range("Protected") = "Y"
ProtectSheets 'Sub to protect certain sheets
Call DeleteEVMenu 'Sub to delete custom menu
ThisWorkbook.Save
End If
End If
End If
End Sub
Any help would be much appreciated