vba script to get list of folders, sub folders and files along with the modification time, size and type of files

exceljack

New Member
Joined
May 28, 2015
Messages
2
Hi Experts,

Please help me with generating a spreadsheet which will have all the folders, sub folders and files with the modification time, size and type. I need to create it for a network drive. I am not familiar with vba scripts and so I am stuck and need it asap.

Please help me.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Welcome to MrExcel forums.

All this can be done with FileSystemObject methods and properties, including recursive traversal of the folder tree.
 
Upvote 0
Thanks John. I tried to work on it but I am not getting the exact result I need. since I am not that familiar with this scripting technique. I managed to get a list of all the folders but what I actually need is columns with folder path, sub folders and files in it with their path along with modification time, size and type. It seems so complicated I am not able to work around it.

Is there any blog where I can get an example or if you have one?
 
Upvote 0
There is a recursive FileSystemObject procedure which does something similar here - http://www.mrexcel.com/forum/excel-...folders-one-level-subfolders.html#post3661579 - which should get you started, but it will need editing for your specific requirements.

For one, delete all references to the folderLevel argument as this is not required for your case.

Also, to make writing the code easier I'd recommend using early binding of FileSystemObject rather than the late binding and Object variables. This means adding a reference to Microsoft Scripting Runtime in Tools - References in the VB editor and changing:
Code:
    Dim FSO As Object
    Dim thisFolder As Object, subfolder As Object    
    Dim fileItem As Object
    Set FSO = CreateObject("Scripting.FileSystemObject")
to:

Code:
    Dim FSO As Scripting.FileSystemObject
    Dim thisFolder As Scripting.Folder, subfolder As Scripting.Folder
    Dim fileItem As Scripting.File
    Set FSO = New Scripting.FileSystemObject
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,218
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top