Sub Archive()
Dim archivage As String
Dim nom As String,[COLOR=red] Fichier As Variant[/COLOR]
Dim datt As String
Sheets("Historique Cde").Unprotect Password:="yves"
If Range("A3").Value = "" Then
MsgBox "Archivage impossible, votre Historique est vide !! ", vbExclamation, "Attention..."
Exit Sub
End If
archivage = MsgBox(" Voulez-vous archivez votre Historique des Commandes ?", vbYesNo + vbExclamation, "Archivage")
If archivage = 7 Then Exit Sub
MsgBox "L'Historique des Commandes sera éffacé et sauvegardé ", vbInformation, "INFO"
datt = CStr(Format(Date, "dd mmmm yyyy"))
nom = CStr("Archive Cde ") & datt & ".xls"
[COLOR=red]Fichier = Application.GetSaveAsFilename(InitialFileName:=nom, FileFilter:="Classeur excel (*.xls),*.xls")[/COLOR]
[COLOR=red][COLOR=black] 'Si choix annuler, sortir[/COLOR]
[/COLOR] [COLOR=red]If Fichier = False Then Exit Sub[/COLOR]
ActiveSheet.Copy
Application.ScreenUpdating = False
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWorkbook.Close True[COLOR=red], Filename:=Fichier[/COLOR]
Application.DisplayAlerts = True
Sheets("Historique Cde").Unprotect Password:="yves"
Call effacehisto
Sheets("Historique Cde").Protect Password:="yves"
Application.ScreenUpdating = True
End Sub