1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| Sub Save_as()
'
' Save_as Macro
'
Dim extention As String
Dim chemin As String
Dim Nomfichier As String
Dim réponse As Byte
chemin = "C:\Dossier Test\"
extention = ".xlsm"
Nomfichier = ActiveSheet.Range("A1")
If Not Dir(chemin & Nomfichier & extention) = "" Then
reponse = MsgBox("Le fichier existe déja, souhaitez vous le remplacer ?", vbYesNo)
If reponse = 6 Then
Application.DisplayAlerts = False
Else
GoTo fin
End If
End If
With ActiveWorkbook
.SaveAs Filename:=chemin & Nomfichier
'.Close
End With
fin:
Application.DisplayFullScreen = False
Application.DisplayAlerts = True
Workbooks.Close
End Sub |
Partager