Sub ContenuChemins()
Dim FSO As New FileSystemObject, Chemin
ActiveSheet.Columns("A:H").ClearContents
ActiveSheet.[A1:H1].Value = Array("Path", "FileName", "Size", "Last modified", "R/O", "Hid.", "Sys", "Chg")
ActiveSheet.[A1].Select
With Application.FileDialog(msoFileDialogFolderPicker)
.AllowMultiSelect = True
.Show
If .SelectedItems.Count = 0 Then Exit Sub
For Each Chemin In .SelectedItems
DossFicSsDoss FSO.GetFolder(Chemin)
Next Chemin
End With
ActiveSheet.[B:H].EntireColumn.AutoFit
End Sub
Sub DossFicSsDoss(ByVal Fdr As Folder)
Dim Fls As Files, Fds As Folders, Fle As File, T(1 To 1, 1 To 8)
If Fdr.Attributes And &H40 Then Exit Sub
T(1, 1) = Fdr.Path
T(1, 5) = IIf(Fdr.Attributes And 2, ChrW$(&H2713), "—")
T(1, 6) = IIf(Fdr.Attributes And 4, ChrW$(&H2713), "—")
T(1, 7) = IIf(Fdr.Attributes And 8, ChrW$(&H2713), "—")
T(1, 8) = IIf(Fdr.Attributes And 32, ChrW$(&H2713), "—")
Selection(2, 1).Select
Selection.Resize(, 8).Value = T
On Error Resume Next ' On peut avoir des Err 70: Permission refusée
Set Fls = Fdr.Files
If Err = 0 Then
For Each Fle In Fls
T(1, 1) = Empty
T(1, 2) = Fle.Name
T(1, 3) = Fle.Size
T(1, 4) = Fle.DateLastModified
T(1, 5) = IIf(Fle.Attributes And 2, ChrW$(&H2713), "—")
T(1, 6) = IIf(Fle.Attributes And 4, ChrW$(&H2713), "—")
T(1, 7) = IIf(Fle.Attributes And 8, ChrW$(&H2713), "—")
T(1, 8) = IIf(Fle.Attributes And 32, ChrW$(&H2713), "—")
Selection(2, 1).Select
Selection.Resize(, 8).Value = T
Next Fle: End If
Err.Clear
Set Fds = Fdr.SubFolders
If Fds.Count = 0 Then Exit Sub
If Err Then Exit Sub
On Error GoTo 0
For Each Fdr In Fds
DossFicSsDoss Fdr
Next Fdr
End Sub