folder hierarchy transfer to excel sheet

N

nerohnze

I need help to copy a large folder hierarchy to excel sheet, available to be
expanded with "+"(grouping) function and including the files in the folder.

Is this possible with programming or with something else?

Thanks for help
 
J

Joel

I you just lookinhg for the file names or do you want to open the files. Do
you need other info beside the filename like last saved date?
 
N

nerohnze

I also need the subfolders, every folder may have a different level
hierarchy. Also, if possible, i need the files in these folders or subfolders.
Thanks in advance for support.
 
J

Joel

The program below will search the entire C:\ drive and get the name, size,
and last modified date. I had the code in my archieves. You can change
strFolder to anything you like for example

strFolder = "C:\temp"
strFolder = "D:\joel\myspace"




Dim RowNumber
Sub GetFolderSize()

strFolder = "C:"
RowNumber = 1

Set fso = CreateObject _
("Scripting.FileSystemObject")
Set folder = _
fso.GetFolder(strFolder)

Sheets(1).Cells(RowNumber, 1) = strFolder + "\"
Sheets(1).Cells(RowNumber, 2) = folder.Size
RowNumber = RowNumber + RowNumber

Call GetSubFolder(strFolder + "\")
End Sub

Sub GetSubFolder(strFolder)
Set fso = CreateObject _
("Scripting.FileSystemObject")

Set folder = _
fso.GetFolder(strFolder)

If folder.subfolders.Count > 0 Then
For Each sf In folder.subfolders
On Error GoTo 100
Call GetSubFolder(strFolder + sf.Name + "\")
100 Next sf
End If
'folder size in bytes
On Error GoTo 200
For Each fl In folder.Files
Sheets(1).Cells(RowNumber, 3) = fl.DateLastModified
Sheets(1).Cells(RowNumber, 2) = fl.Size
Sheets(1).Cells(RowNumber, 1) = strFolder & fl.Name
RowNumber = RowNumber + 1
Next fl

200 On Error GoTo 0

End Sub
 
J

Jim Cone

My List Files Excel add-in generates a file/folder list with a grouping
and hyperlink option. All done with a few button clicks.
The trial version is available to those responding (via email) who
provide a real name and geographic location.
Remove XXX from my email address.
--
Jim Cone
Portland, Oregon USA
(e-mail address removed)



"nerohnze"
<[email protected]>
wrote in message
I need help to copy a large folder hierarchy to excel sheet, available to be
expanded with "+"(grouping) function and including the files in the folder.
Is this possible with programming or with something else?
Thanks for help
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top