Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Range("A1") = "" Then
MsgBox "Remplir A1 !", vbExclamation + vbOKOnly, "Attention"
Cancel = True
End If
End Sub
Une autre solution consiste a redefinir la fonction "save"
Private Sub Workbook_Open()
Sheet1.Select
Range("C6").Select
Application.OnKey "^s", "mysave3" ' les touches CTRL-S renvoient vers la function mysave3.
'when openning this workbook, the decimal sign will change to "."
'the auto save time for all open documents is changed to 10 minutes.
With Application
.DecimalSeparator = ","
.ThousandsSeparator = "."
.UseSystemSeparators = False
End With
Application.AutoRecover.Time = 10
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.OnKey "^s" 'here the save function is restored
Application.UseSystemSeparators = True
End Sub