Option
Explicit
Const
WKS_NAME
As
String
=
"Tabelle1"
Const
PFAD
As
String
=
"C:\Windows"
Dim
fso
As
FileSystemObject
Dim
wks
As
Worksheet
Dim
f
As
folder
Public
Sub
list_all_files()
Set
fso =
New
FileSystemObject
Set
wks = Worksheets(WKS_NAME)
Call
get_all_files_of_subfolder(PFAD)
End
Sub
Private
Sub
get_all_files_of_subfolder(
ByVal
sPfad
As
String
)
Dim
fo
As
folder
Dim
sfo
As
Folders
Dim
fi
As
file
Dim
i
As
Integer
Set
fo = fso.GetFolder(sPfad)
Set
sfo = fo.SubFolders
i = wks.Cells(wks.Rows.Count, 1).
End
(xlUp).Row
For
Each
fi
In
fo.Files
With
wks
.Cells(i, 1) = fi.Path
.Cells(i, 2) = fi.Name
.Cells(i, 3) = fi.DateCreated
.Cells(i, 4) = fi.Type
End
With
i = i + 1
Next
For
Each
f
In
sfo
Call
get_all_files_of_subfolder(f.Path)
Next
End
Sub