Bonjour à toutes et tous.

Qui pourrait me modifier cette macro pour qu'elle enregistre le fichier dans un sous répertoire reprenant la valeur de" B2" (nom_client) pour obtenir :
"D:\Mes Documents\nom_client\........(Fich).xls"

Merciiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii ii.................

PS : cette macro a été trouvée sur le net et je sais plus où.... d'où ma demande.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
32
33
Sub Enregistrement01()
 
Dim Rep As String, Fich As String, C As Byte, Cancel, Q As String
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Rep = "D:\Mes Documents\"
 
With ActiveWorkbook
Fich = Range("B2") & "_" & "_" & Range("C2") & "_" & "_" & Range("D1")
For C = 1 To Len(Fich) 'test caractères interdits
If InStr("\/:*?""""<>|", Mid(Fich, C, 1)) > 0 Then
MsgBox "Attention, il y a des des caractères interdits !"
Cancel = True
Exit Sub
End If
Next
If dir(Rep & Fich & ".xls") <> "" Then 'test existence fichier
Q = MsgBox(Fich & " Existe déjà, voulez-vous le remplacer ?", vbYesNo)
If Q = 7 Then GoTo Ligne1 Else GoTo Ligne2
Else: GoTo Ligne2
End If
 
Ligne1:
Cancel = True
Exit Sub
Ligne2:
.SaveAs Rep & Fich & ".xls"
 
End With
Application.ScreenUpdating = True
Application.DisplayAlerts = True
 
End Sub