I'm not sure if you found your answer, as this thread is a bit outdated, but I thought I would bet my $ 0.02.
I create a named range [isDirty] on an unlocked, very dangerous worksheet and on every visible worksheet. Change the setting [isDirty] = True
In Workbook.BeforeClose, I have the following:
If [IsDirty] = True Then Select Case MsgBox("Do you want to save the changes you made to '" & .Name & "'?", _ vbYesNoCancel + vbExclamation) Case Is = vbYes ThisWorkbook.Save [IsDirty] = False Case Is = vbNo 'Do not save Case Is = vbCancel Cancel = True End Select End If
In Private Sub Workbook_BeforeSave (ByVal SaveAsUI As Boolean, Cancel As Boolean)
ThisWorkbook.Save [IsDirty] = False Cancel=True
source share