Private Sub Workbook_BeforeClose(Cancel As Boolean)
Select Case MsgBox("Library Management System" & vbNewLine & vbNewLine & "Save and Close?", vbOKCancel)
' Cancel button pressed, so cancel the close
Case Is = vbCancel
Cancel = True
' OK button pressed, so save the workbook and close
Case Is = vbOK
ThisWorkbook.Close SaveChanges:=True
'Close Select Case statement
End Select
End Sub
This code re-enters the Before_Close routine when it executes the ThisWorkbookClose statement so the Msgbox is output again.
Why ? And can this be avoided ?
Bookmarks