• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

File Name List

umizoomi

New Member
I have a folder with multiple sub-folders, 7 actually, each folder with 5 - 7 files. Files are a random mix of PDF, *.doc, *.docx, *.xls, *.xlsx formats. Is there a routine that can be run that extracts the name of each file into an excel "index/table of contents" for easy reference? Having a method to conquer this would be a huge help.
 
Since you have subfolders that you want to check, I'd go with Scripting.FileSystemObject. While it's a bit slower, it's much easier to traverse through subfolders.

There's example code found in below link. Note that you need to add reference to Microsoft Scripting Runtime (as explained at the top of the link).

http://www.xl-central.com/list-the-files-in-a-folder-and-subfolders.html

If you want to list File Name with full path (instead of just file name) then replace below line in "Sub RecursiveFolder".
Code:
Cells(NextRow, "A").Value = objFile.Name
With
Code:
Cells(NextRow, "A").Value = objFile.Path
 
Back
Top