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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| Option Explicit
Dim oSheetD As Worksheet
Dim oSheetF As Worksheet
Dim sRacine As String
Dim ligne1 As Long
Dim ligne As Long
Dim NbFich As Long
Dim fs
Dim Fldracine
Dim oSFld
Dim oFiche
Dim NbFiche
Sub recup()
Set oSheetD = Worksheets("Folders")
Set oSheetF = Worksheets("Files")
Application.ScreenUpdating = False
'Chemin'
sRacine = "H:\My Documents"
If sRacine = "" Then
MsgBox "racine"
End If
oSheetF.Activate
Range("A1").CurrentRegion.Clear
oSheetD.Activate
ligne1 = 1
ligne = ligne1
NbFiche = 1
Range("A" & ligne1).CurrentRegion.Clear
Set fs = CreateObject("Scripting.FileSystemObject")
Set Fldracine = fs.getfolder(sRacine)
lit_oFld Fldracine, 1
End Sub
Sub lit_oFld(ByRef oFld, ByVal Niveau)
oSheetD.Cells(ligne, Niveau) = CStr(oFld.Name)
oSheetD.Hyperlinks.Add anchor:=oSheetD.Cells(ligne, Niveau), Address:=oFld.Path, TextToDisplay:=oFld.Name
Application.StatusBar = NbFich & "-" & oFld.Name
For Each oFiche In oFld.Files
On Error Resume Next
oSheetF.Cells(NbFiche, 1) = oFiche.Name
oSheetF.Cells(NbFiche, 2) = oFld.Name
oSheetF.Cells(NbFiche, 3) = oFiche.DateLastModified
oSheetF.Cells(NbFiche, 4) = oFiche.Size / 1000 ^ 3 'taille fichier en GO'
oSheetF.Cells(NbFiche, 5) = oFiche.Path
oSheetF.Hyperlinks.Add anchor:=oSheetF.Cells(NbFiche, 1), Address:=oFld.Path & "\" & oFiche.Name, TextToDisplay:=oFiche.Name
NbFiche = NbFiche + 1
Next
ligne = ligne + 1
For Each oSFld In oFld.subfolders
lit_oFld oSFld, Niveau + 1
Next
End Sub |
Partager