Count files in a dir

raindrop3

Registered User.
Local time
Today, 19:12
Joined
Sep 6, 2001
Messages
98
Hi,

I need to know how much files are in a dir. There may be no more than 150 in a dir. How do I count the files in a dir??

Short question, big trouble.....

Thanks,

Albert
 
Hi,

I use the following, which calls the Excel function FileSearch (ensure Microsoft Excel Object Library is referenced under Tools, References)

With Application.FileSearch
.Lookin = "c:\MyDir"
.SearchSubFolders = False (or True depending)
.Filename = "*.*" (or any file pattern you choose)
.Execute
myFileCount = .FoundFiles.Count
End With

HTH
wink.gif


[This message has been edited by PearlGI (edited 11-28-2001).]
 
Works great! Thanks.

However, can I also count the number of (sub)directorys in a certain dir?

Thanks.

Albert
 
Look at the DIR function in the help files. There is code there which can be easily amended to count instead of displaying names.

HTH
 

Users who are viewing this thread

Back
Top Bottom