Results 1 to 2 of 2
2002-06-18, 07:00 #1
- Join Date
- Jun 2001
- New York, New York, Lebanon
- Thanked 1 Time in 1 Post
FileSearch for folders (Excel 97 to 2002)
<img src=/S/hello.gif border=0 alt=hello width=25 height=29> Loungers
OK what is the best way to use the FileSearch wrapper to find folders in a specific path and count them?
I need to determine how many folders, their names, and sizes for an automated backup system that we are writing at work.
I tried the Attribute 16, but maybe I did something wrong, it missed about 90% of the folder entries in my test path <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
Thanks for anyone who provides a sample code snipit.
Wassim <img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22><img src=/S/compute.gif border=0 alt=compute width=40 height=20> in the <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>
2002-06-18, 21:36 #2
- Join Date
- Feb 2001
- Dublin, Ireland, Republic of
- Thanked 0 Times in 0 Posts
Re: FileSearch for folders (Excel 97 to 2002)
I think the FileSystem Object might be better suited. See if the following code can help in any way : <pre>Sub ListFolders(strPath As String)
Dim fso As Object, fldr As Object, subFldr As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set fldr = fso.GetFolder(strPath)
For Each subFldr In fldr.Subfolders
Debug.Print subFldr.Path, Format(subFldr.Size, "#,##0")
<font color=blue>If subFldr.Subfolders.Count > 0 Then ListFolders (subFldr.Path)</font color=blue>
Set subFldr = Nothing
Set fldr = Nothing
Set fso = Nothing
The line in blue recursively calls the routine to provide a listing of nested folders, and can be omitted.