View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Tom Ogilvy
 
Posts: n/a
Default How to decide folder-depth or How to select more folders/subfolders (folder-tree) ?

http://www.j-walk.com/ss/excel/tips/tip29.htm

--
Regards,
Tom Ogilvy


"Subteam" wrote in message
t...
Hello to you all,

I have got some VBA code that allows a user (mainly me) to select a

folder
on which I will do some renaming en converting of data. (also in

VBA-excel)

Folder structure can be eg:
C:\Afolder\Bfolder\Cfolder\Dfolder\Efolder

If you select DFolder ... my code will do its thing on all Efolders.
Efolder is always the same structure (contains alos subfolder) but amount

of
Efolders can vary.

If user selects Bfolder or Cfolder my code doesn't work because I only

look
one subfolder deep.

I have used the following code to look into subfolder:

Dim fl
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(FolderName) ' FolderName is retrieved by some
other code
Set fc = f.SubFolders
For Each f1 In fc
'Do my thing
Next

Is there a variable in VBA or this object which tells you how deep the
folders list is?
In other words ... how many subfolder levels there are?

Or is this done by going down the path of subfolders and just count it

your
self?



EVEN better or ALSO LOOKING FOR:

Is there an object/dialog within VBA that show you the folder tree

structure
and allows you to select / deselect folders on which you can run your

code.

(if possible ... for Excel2000 or show me the way for ExcelXP and I will

try
to translate it)



Many Thanks in Advance


Kimball