I have a workbook with few sheets in it.
I the beforeClose I use ThisWorkbook.Saved to show a enhanged dialog explaining in danish the situation for the user - it's just the normal problematic ... do you want to save or not or cancel then close the file - here is the code:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
' Application.DisplayFormulaBar = True
' ActiveWindow.Zoom = initZoom
' ActiveSheet.Range("A1").Select
'
Dim svar As Byte
If ThisWorkbook.Saved = False Then
svar = MsgBox("Du har lavet ændringer på et af arkene - bevidst eller ubevidst !" & vbLf & vbLf & _
"Er du USIKKER på, hvad du har lavet --> så svar NEJ til at gemme !" & vbLf & vbLf & _
"Overvej nøje HVAD du har lavet, og besvar så dette: 'Vil du gemme ?'", _
vbYesNoCancel + vbDefaultButton2, "ADVARSEL <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
If svar = vbYes Then
ThisWorkbook.Save
ElseIf svar = vbNo Then
ThisWorkbook.Saved = True
ElseIf svar = vbCancel Then
Cancel = True
End If
End If
End Sub
If I just open the file and close it again the dialog shows up ... as though the ThisWorkbook.Saved is False ... but I'm not aware of making any changes or having some vba that do any changes to the file !
How can I find out where the chance happens ?