One way to do it is to use the Dir function. An example function is shown below:
Function CountFiles(Folder)
CountFiles = 0
FileName = Dir(Folder)
While Len(FileName) > 0
CountFiles = CountFiles + 1
FileName = Dir
Wend
End Function
To count the files in the root folder of the C drive, you would then use
NoOfFiles = CountFiles("C:\"
In a lower level folder an example might be:
NoOfFiles = CountFiles("C:\SomeFolder\"
Make sure you dont forget the last backslash.
If you want to count just the .doc file, you could use:
NoOfFiles = CountFiles("C:\SomeFolder\*.doc"
Hope this helps,
Cheers,
Steve Lewy
Solutions Developer
steve@lewycomputing.com.au