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 34 35 36 37
| Sub Dossier()
Dim Chemin As String, OldName As String, NewName As String, DR As String
Dim Ligne As Integer, i As Integer
'Détermine le chemin d'accès
Chemin = Application.InputBox(Prompt:="Copier/Coller l'adresse du répertoire où se trouve l'export.")
Range("P2") = Chemin
Chemin = Chemin + "\"
'Nettoie les colonnes éventuellement déjà utilisées
Columns("CY:DJ").Select
Selection.ClearContents
Ligne = ActiveSheet.UsedRange.Rows.Count
'DR = Mid(Cells(5, 4), 7, InStr(Cells(5, 4), ": ")) & "\"
For i = 15 To Ligne
For j = 103 To 115
If Cells(i, j - 100) = "" Then
Cells(i, j) = Cells(i - 1, j)
Else
Cells(i, j) = Cells(i, j - 100) & "\"
'Chemin2 = Chemin & DR & Cells(i, 103) & Cells(i, 104) & Cells(i, 105) & Cells(i, 106) & Cells(i, 107) & Cells(i, 108) & Cells(i, 109) & Cells(i, 110) & Cells(i, 111) & Cells(i, 112) & Cells(i, 113) & Cells(i, 114)
Chemin2 = Chemin & Cells(i, 103) & Cells(i, 104) & Cells(i, 105) & Cells(i, 106) & Cells(i, 107) & Cells(i, 108) & Cells(i, 109) & Cells(i, 110) & Cells(i, 111) & Cells(i, 112) & Cells(i, 113) & Cells(i, 114)
MkDir Chemin2
On Error Resume Next
End If
Next
If Cells(i, 15) <> "" Then
OldName = Chemin & "Documents\" & Cells(i, 18) & ".pdf"
NewName = Chemin2 & Cells(i, 16) & Right(OldName, 4)
On Error Resume Next
Name OldName As NewName
End If
Next
End Sub |
Partager