Sub enregistremen()
Dim NomFichier As String
Dim date1 As String
Dim Nomfeuille1 As String
On Error GoTo CommandButton_Error
Nomfeuille1 = "Extract"
date1 = CStr(Sheets(Nomfeuille1).Range("c2"))
date1 = Replace(date1, "/", "_")
date1 = Replace(date1, ":", "_")
NomFichier = date1 & ".xls"
Application.DisplayAlerts = False
Sheets(Nomfeuille1).Copy
ActiveWorkbook.SaveAs Filename:= _
NomFichier, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWorkbook.Close
Application.DisplayAlerts = True
On Error GoTo 0
Exit Sub
CommandButton_Error:
'en cas d'erreur on reprend la main
ActiveWorkbook.Close
Application.DisplayAlerts = True
MsgBox "La sauvegarde n'a pas été effectuée : Répertoire inconnu ou Annulation"
On Error GoTo 0
End Sub