Private Sub Workbook_Open()
Dim w As Window
For Each w In Me.Windows: w.Visible = True: Next 'il peut y avoir plusieurs fenêtres sur un même classeur
Me.Saved = True
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
If Me.Saved Then Exit Sub
Dim w As Window
Application.ScreenUpdating = False
For Each w In Me.Windows: w.Visible = False: Next
Application.EnableEvents = False
Me.Save
Application.EnableEvents = True
Workbook_Open 'lance cette macro
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Me.Saved Then Exit Sub
Select Case MsgBox("Voulez-vous enregistrer les modifications faites sur '" & Me.Name & "' ?", 51)
Case 2: Cancel = True 'Annuler
Case 7: Me.Saved = True 'Non
Case 6 'Oui
Workbook_BeforeSave False, False 'lance cette macro
If Workbooks.Count = 1 Then Application.Quit Else Me.Close
End Select
End Sub