Friday, March 4

Count number of files in a folder

Dim iFileCount, FolderName, vFiles, objFSO
iFileCount = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set FolderName = objFSO.GetFolder("C:\Desktop") ' Folder Path
Set vFiles =FolderName.Files

For each vFile in vFiles
    Print vFile
    iFileCount = iFileCount + 1
msgbox iFileCount

Above code will print names of all the file in given folder and display the total count of files.


  1. This is my first time visit to your blog and I am very interested in the articles that you serve. Provide enough knowledge for me. Thank you for sharing useful and don't forget, keep sharing useful info: legal entity identifier