Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not ThisWorkbook.Saved Then ThisWorkbook.Save
Cancel = Not ThisWorkbook.Saved
End Sub
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
File = [D3] & ", mesures " & Format(Date, "dd-mm-yyyy") & "_" & Format(Time, "hh-mm") & ".xlsm"
Fname = Application.GetSaveAsFilename(Title:="Enregistrement forcée du Classeur", _
InitialFileName:=File, filefilter:="Xlsm Files (*.xlsm), *.xlsm")
If Not Fname = False Then
ActiveWorkbook.SaveAs Filename:=Fname, FileFormat:=xlOpenXMLWorkbookMacroEnabled
Else
Cancel = True
End If
End Sub