Although if I have the following code
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "Hello"
Application.DisplayAlerts = False
If Not ActiveWorkbook.Saved Then ActiveWorkbook.Save
End Sub
the workbook still ask to be saved why?
The "Hello" is displayed after the excel pop-up for saving the workbook
The expected behaviour is to avoid the "Do you want to save the workbook" pop-up on closing it (see picture below)
UPDATE
all lines of code in Workbook_BeforeClose
are fired but although the ActiveWorkbook.Save
is fired, the pop-up above still show up
UPDATE 2 Finally I figured it out or at least this solution worked for me after reading this post on StackOverflow I then just out of curiosity disabled the "Analysis ToolPack" add-in and bum.. all work fine now.
Any comments?