Sub Save_as()
desti = Sheets(1).Range("AA3").Value
If desti = "S1" Then
Fred_ ("A2") 'ici on lance la macro Fred avec passage du parametre : "A2"
End If
If desti = "S2" Then
Fred_ ("A3")
End If
If desti = "S3" Then
Fred_ ("A4")
End If
If desti = "S4" Then
Fred_ ("A5")
End If
If desti = "S5" Then
Fred_ ("A6")
End If
If desti = "S6" Then
Fred_ ("A7")
End If
If desti = "S7" Then
Fred_ ("A8")
End If
If desti = "S8" Then
Fred_ ("A9")
End If
If desti = "S9" Then
Fred_ ("A10")
End If
If desti = "S10" Then
Fred_ ("A11")
End If
If desti = "S11" Then
Fred_ ("A12")
End If
If desti = "S12" Then
Fred_ ("A13")
End If
If desti = "" Then
Erreur = "La celulle 'AA3' doit contenir une destination"
End If
If desti <> "" And desti <> "S1" And desti <> "S2" And desti <> "S3" _
And desti <> "S4" And desti <> "S5" And desti <> "S6" And desti <> "S7" And _
desti <> "S8" And desti <> "S9" And desti <> "S10" And desti <> "S11" And _
desti <> "S12" Then
Erreur = "Répèrtoire non identifié"
End If
If Erreur <> "" Then
CreateObject("WScript.Shell").Popup Erreur & vbLf & vbLf & vbLf & vbLf & _
"Voici le racourcis a rentrez dans la celulle 'AA3' pour les destinations :" & vbLf & vbLf & _
"S1 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A2")).Value & vbLf & _
"S3 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A3")).Value & vbLf & _
"S4 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A4")).Value & vbLf & _
"S5 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A5")).Value & vbLf & _
"S6 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A6")).Value & vbLf & _
"S7 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A7")).Value & vbLf & _
"S8 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A8")).Value & vbLf & _
"S9 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A9")).Value & vbLf & _
"S10 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A10")).Value & vbLf & _
"S11 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A11")).Value & vbLf & _
"S12 --> " & Workbooks("Personl.xls").Sheets("destination").Range(("A12")).Value & vbLf _
, 2, "Gestion des erreurs"
End If
Application.DisplayAlerts = True
Erreur = ""
End Sub
Sub Fred_(MaCellule As String)
Dim Fichier, Fichier_Origine, Path, Perso
Perso = ActiveWorkbook.Name
Fichier_Origine = ActiveWorkbook.FullName
Fichier = Workbooks(Perso).Sheets(1).Range("A3").Value & ".xls"
Path = Workbooks("Personl.xls").Sheets("Destination").Range(MaCellule).Value
If Path = "" Then
Erreur = "Aucun répèrtoire de mémoriser"
Else
If Sheets(1).Range("A3").Value = "" Then
Erreur = "Aucun nom"
Else
If Fichier = Fichier_Origine Then
Erreur = "Meme nom, meme répèrtoire"
Else
If Dir(Path & "\" & Fichier) = "" Then
Workbooks(Perso).SaveAs Filename:=Path & Fichier
'Kill Fichier_Origine ' ici on peut si l'ont veut effacer le fichier d'origine
CreateObject("WScript.Shell").Popup "Nouveau fichier créer dans :" & _
vbLf & vbLf & Path & vbLf & vbLf & vbLf & "Nom du fichier : " & _
Fichier & vbLf, 3, "Fred"
Else
Erreur = "le fichier existe déja dans le répèrtoire de déstination ..."
End If
End If
End If
End If
End Sub