L
Laurence Lombard
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
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