+ Reply to Thread
Results 1 to 3 of 3

How to decide folder-depth or How to select more folders/subfolders (folder-tree) ?

  1. #1
    Subteam
    Guest

    How to decide folder-depth or How to select more folders/subfolders (folder-tree) ?

    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



  2. #2
    Tom Ogilvy
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    > 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
    >
    >




  3. #3
    Subteam
    Guest

    Re: How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Still looking

    Hello Tom,

    Thanks for the fast reply ... unfortunately it does not answer my
    question(s).

    I actually already use code like that to select the folder.

    The problem is in the fact that the user (or myself) can select the Dfolder
    (see earlier mail) and my code will do its thing. But If I decide to do a
    batchjob (more Dfolders at once) I must have a way to detect the folder
    depth.

    eg.

    now I have:
    c:\Afolder\Bfolder\Cfolder\Dfolder_1\Efolder_1
    ....
    c:\Afolder\Bfolder\Cfolder\Dfolder_1\Efolder_5


    After selecting Dfolder_1 my code knows what to do with all found Efolders.

    What I'm looking for is

    c:\Afolder\Bfolder\Cfolder\Dfolder_1\Efolder_1
    ....
    c:\Afolder\Bfolder\Cfolder\Dfolder_1\Efolder_5

    c:\Afolder\Bfolder\Cfolder\Dfolder_2\Efolder_1
    ....
    c:\Afolder\Bfolder\Cfolder\Dfolder_2\Efolder_7

    c:\Afolder\Bfolder\Cfolder\Dfolder_3\Efolder_nottobeused1
    ....
    c:\Afolder\Bfolder\Cfolder\Dfolder_3\Efolder_nottobeused2



    If select Cfolder .... code has to be able to detect that there are more
    than 1 Dfolders and prefeblably one can select 1 or more Dfolders on which
    the code will work.

    This Batch idea is an example .... folder levels shown here are also
    flexible (not always the same)

    Thats why I am looking for some sort of folder-tree in which you can select
    the folders (more than one) on which I can do my thing. This rather than
    finding out the folder depth.

    >>>>>> This looks a bit like selecting folders for backup in backup
    >>>>>> tools/programs. <<<<<


    Maybe this triggers somebodies brilliant mind.

    Kimball





    "Tom Ogilvy" <[email protected]> schreef in bericht
    news:%[email protected]...
    > http://www.j-walk.com/ss/excel/tips/tip29.htm
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Subteam" <[email protected]> wrote in message
    > news:[email protected]...
    >> 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
    >>
    >>

    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1