Posted to microsoft.public.excel.programming
|
|
Creating a list of Subfolders and sizes
Doesn't that link just use the exact same technology the OP posted.
--
Regards,
Tom Ogilvy
"Naveen" wrote:
See ...
http://www.exceltip.com/st/List_file...Excel/446.html
*** Please do rate ***
"Laurence Lombard" wrote:
I would like to be able to list the subfolders in any specified folder with
their respective sizes. In a search for a solution I copied this section
from the VBA's help, but this is not a standalone bit of code (why do they
not use standalone code for their examples?)
Sub ShowFolderList(folderspec)
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.SubFolders
For Each f1 In fc
s = s & f1.Name & " " & f1.Size 'I added the "Size" bit
s = s & vbCrLf
Next
MsgBox s
So I wrote this bit to call the above code
Sub test3()
folderspec = "C:\"
ShowFolderList (folderspec)
End Sub
However the line containing "Scripting.FileSystemObject" creates an error
"Runtime error 429 - ActiveX component can't create object"
What should folderspec be? How do I get it to work?
My VBA is self taught and I come unstuck when the help talks about
SearchFolders and ScopeFolders!
Thanks
Laurence
|