I have the following code in ThisWorkbook
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Did you PW protect this file?", vbInformation + vbYesNo + vbDefaultButton1, "Please Confirm before Closing") = vbNo Then
Cancel = True
Else
ActiveWorkbook.Close
End If
End Sub
When I click yes, the pop up message does not close. I have to click it once more and then it will exit. How can I make it close after clicking "yes" just once?
thank you.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Did you PW protect this file?", vbInformation + vbYesNo + vbDefaultButton1, "Please Confirm before Closing") = vbNo Then
Cancel = True
Else
ActiveWorkbook.Close
End If
End Sub
When I click yes, the pop up message does not close. I have to click it once more and then it will exit. How can I make it close after clicking "yes" just once?
thank you.