Dim fPath As String, sName As String, n As Integer
fPath = "c:\" sName = Dir(fPath & "*.txt")
Do Until sName = "" n = n + 1 sName = Dir() Loop
Debug.Print n
Dim n As LongPrivate Sub Command1_Click() Call a("E:\") Debug.Print n End SubSub a(sDir As String) Dim fs, ds, d, f Set fs = CreateObject("Scripting.FileSystemObject") Set ds = fs.getfolder(sDir) For Each f In ds.Files If UCase(Right(f.Shortname, 3)) = "EXE" Then n = n + 1 Next f For Each d In ds.SubFolders a d.Path Next d End Sub
fPath = "c:\"
sName = Dir(fPath & "*.txt")
Do Until sName = ""
n = n + 1
sName = Dir()
Loop
Debug.Print n
Call a("E:\")
Debug.Print n
End SubSub a(sDir As String)
Dim fs, ds, d, f
Set fs = CreateObject("Scripting.FileSystemObject")
Set ds = fs.getfolder(sDir)
For Each f In ds.Files
If UCase(Right(f.Shortname, 3)) = "EXE" Then n = n + 1
Next f
For Each d In ds.SubFolders
a d.Path
Next d
End Sub