Return to Snippet

Revision: 76992
at August 10, 2019 23:11 by martinbrait


Initial Code
Option Explicit
Sub ListeFichiersRepert()
Dim Fso  As Object
Dim MonRepertoire As String, f As Object, x As Integer
Dim f1 As  Object, f2 As Object
Set Fso =  CreateObject("Scripting.FileSystemObject")
MonRepertoire =  "C:\Users\Moi\Documents\Dossier Excel"
x = 1
For Each f In  Fso.GetFolder(MonRepertoire).Files
    Cells(x, 1).Value = f.Name
    x =  x + 1
Next f
x = 1
For Each f1 In  Fso.GetFolder(MonRepertoire).SubFolders
    Cells(x, 2).Value =  f1.Name
    x = x + 1
    For Each f2 In f1.Files
        Cells(x - 1,  3).Value = f2.Name
        x = x + 1
    Next f2
    x = x - 1
Next  f1
End Sub

Initial URL

                                

Initial Description
How to list files in directories and subdirectories ?

Initial Title
[vba-excel] lister tous les fichiers répertoires et sous-répertoires

Initial Tags
list, path, files

Initial Language
Visual Basic