Obtain Sub-Folder Names with VBA?

B

Brad

Is it possible to obtain the names of all Sub-Folders for a specific parent
Folder?

Just 2 levels (1 Parent Folder) and several children folders.

We need the names of the sub-folders, not the names of the files in the
sub-folders.

Thanks for your help.
Brad
 
S

Stuart McCall

Brad said:
Is it possible to obtain the names of all Sub-Folders for a specific
parent
Folder?

Just 2 levels (1 Parent Folder) and several children folders.

We need the names of the sub-folders, not the names of the files in the
sub-folders.

Thanks for your help.
Brad

Try this:

http://www.smccall.demon.co.uk/Downloads.htm#FsRecurse

Store the folder names as they are discovered, in the FolderFound event,
into a collection, table, etc.
 
A

Allen Browne

Use Dir to list the files that have the vbDirectory attribute set, adn then
GetAttr() to test if it is a folder. The FileExists() and FolderExists()
functions here illustrate using those functions:
http://allenbrowne.com/func-11.html

This code lists files in a folder and its subfolders recursively:
http://allenbrowne.com/ser-59.html
Use that approach if you need to go down the tree further (i.e. the
sub-subfolders below that etc.)
 
B

Brad

Allen, Daniel, Stuart,

Thanks to all of you for the ideas/help.

You guys are great!

I have it working already with your help.

Brad
 

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