Dim ligne, nivMax
Sub arborescenceRepertoire()
racine = ChoixDossier() ' ou un répertoire C:\xxx e.g.
If racine = "" Then Exit Sub
Range("A2:A30000").ClearContents
lignedeb = 2
Set fs = CreateObject("Scripting.FileSystemObject")
Set dossier_racine = fs.GetFolder(racine)
ligne = lignedeb
nivMax = 4
Lit_dossier dossier_racine, 1, nivMax, ""
End Sub
Sub Lit_dossier(ByRef dossier, ByVal niveau, ByVal nivMax, parent)
Cells(ligne, 1) = dossier.Path
Cells(ligne, 2) = dossier.Path
ligne = ligne + 1
For Each d In dossier.SubFolders
If niveau <= nivMax Then Lit_dossier d, niveau + 1, nivMax, dossier.Path
Next
End Sub
Function ChoixDossier()
If Val(Application.Version) >= 10 Then
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = ActiveWorkbook.Path & "\"
.Show
If .SelectedItems.Count > 0 Then
ChoixDossier = .SelectedItems(1)
Else
ChoixDossier = ""
End If
End With
Else
ChoixDossier = InputBox("Répertoire?")
End If
End Function
Sub modifie()
Set Rng = Range("A2:A" & [A65000].End(xlUp).Row)
For Each c In Rng
chemin1 = c.Value
chemin2 = c.Offset(, 1).Value
Name chemin1 As chemin2
Rng.Replace chemin1, chemin2
Set Rng2 = Range("A" & c.Row + 1 & ":A" & [A65000].End(xlUp).Row)
Rng2.Offset(, 1).Replace chemin1, chemin2
Next c
End Sub