In Windows Explorer, when you right-click a folder and select Properties (or just select the folder and press ALT+ENTER), you get all sorts of useful information, including the total count of files and folders contained inside (not just directly inside, but the total recursive count).
I may be doing it wrong, but my understanding of VBA's FileSystemObject Folder object is that to get this total count of folders and/or files you have to recursively iterate through each subfolder and add up the Folder.Files.Count or Folder.Folders.Count to get the total total count. I haven't seen a "total total" file or folder count property for the Folder object.
For folders with many many files, this recursive counting method can take a while. VBA took 8+ minutes to get a count for the contents of a folder on a large hard drive. But when I click on the folder and get properties, Windows Explorer gave me the file+folder count in under 5 seconds!
So my question for you VBA gurus is: how, using either an API call or whatever way that is not too involved (ie it will run in most people's (Windows 7/8) Excel VBA (2007-2013) without installing anything special), can we access the Explorer file/folder "Properties" function, to QUICKLY retrieve a file and folder count of a given folder (and maybe other useful properties too?)
From what I've seen as a Windows user and VBA developer, it seems this sort of thing should be possible. Thoughts?
I may be doing it wrong, but my understanding of VBA's FileSystemObject Folder object is that to get this total count of folders and/or files you have to recursively iterate through each subfolder and add up the Folder.Files.Count or Folder.Folders.Count to get the total total count. I haven't seen a "total total" file or folder count property for the Folder object.
For folders with many many files, this recursive counting method can take a while. VBA took 8+ minutes to get a count for the contents of a folder on a large hard drive. But when I click on the folder and get properties, Windows Explorer gave me the file+folder count in under 5 seconds!
So my question for you VBA gurus is: how, using either an API call or whatever way that is not too involved (ie it will run in most people's (Windows 7/8) Excel VBA (2007-2013) without installing anything special), can we access the Explorer file/folder "Properties" function, to QUICKLY retrieve a file and folder count of a given folder (and maybe other useful properties too?)
From what I've seen as a Windows user and VBA developer, it seems this sort of thing should be possible. Thoughts?