Dim ligne
Sub arborescenceRepertoire()
racine = ChoixDossier() ' ou un répertoire C:\xxx e.g.
If racine = "" Then Exit Sub
Range("A:E").ClearContents
Set fs = CreateObject("Scripting.FileSystemObject")
Set dossier_racine = fs.getfolder(racine)
ligne = 3
Lit_dossier dossier_racine, 1
End Sub
Sub Lit_dossier(ByRef dossier, ByVal niveau)
Cells(ligne, niveau) = dossier.Name
[COLOR=#ff0000]Cells(ligne, niveau).Font.ColorIndex = 0[/COLOR]
ligne = ligne + 1
[COLOR=red] For Each f In dossier.Files[/COLOR]
[COLOR=red] Cells(ligne, niveau) = f.Name[/COLOR]
[COLOR=red] Cells(ligne, niveau).Font.ColorIndex = 3[/COLOR]
[COLOR=red] ligne = ligne + 1[/COLOR]
[COLOR=red] Next[/COLOR]
For Each d In dossier.SubFolders
Lit_dossier d, niveau + 1
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