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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
Sub Arborescence()
Application.ScreenUpdating = False
Dim fd As FileDialog
Dim Racine As String
Racine = ThisWorkbook.Path
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Racine & "\"
.Title = "Sélectionner le Dossier Racine"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewDetails
.ButtonName = "Sélection Dossier"
.Show
MsgBox "Vous avez sélectionné le répertoire : " & .SelectedItems(1), vbInformation
If .SelectedItems.Count > 0 Then
Chemin = .SelectedItems(1)
End If
End With
If Racine = "" Then Exit Sub
Range("A:E").Clear
Range("A3").Select
Set fs = CreateObject("Scripting.FileSystemObject")
Set dossier_racine = fs.getfolder(Chemin)
Lit_dossier dossier_racine, 1
Range("A1").Select
End Sub
Sub Lit_dossier(ByRef dossier, ByVal niveau)
With ActiveCell.Font
.Size = 11
.Underline = True
.Bold = True
ActiveCell.Value = decal(niveau - 1) & "--------> " & dossier.Name & " <-------- "
ActiveCell.Interior.ColorIndex = 33
ActiveCell.Offset(1, 0).Select
For Each d In dossier.SubFolders
Lit_dossier d, niveau + 1
Next
For Each f In dossier.Files
nom_fich = f.Name
ActiveSheet.Hyperlinks.Add Anchor:=Selection, _
Address:=dossier.Path & "\" & nom_fich, TextToDisplay:="" & nom_fich
ActiveCell.Offset(0, 1) = f.Size
ActiveCell.Offset(0, 2) = f.DateLastModified
ActiveCell.Offset(0, 3) = f.Attributes
If f.Attributes And vbHidden Then ActiveCell.Offset(0, 4) = "Caché"
ActiveCell.Interior.ColorIndex = 2
ActiveCell.Offset(1, 0).Select
Next
End With
End Sub
Function decal(niv)
decal = String(3 * niv, " ")
End Function |
Partager