+ Reply to Thread
Results 1 to 7 of 7

traversing file system vba

  1. #1
    Registered User
    Join Date
    12-19-2007
    Posts
    1

    traversing file system vba

    Hi all,

    I'm trying to write a macro that is given a directory as input, and looking
    for .txt file in that directory and in all of that directory sub-directories, and those sub-directories sub-directories and so on ...
    The result is a list of the .txt files found.

    Is that possible?
    Any help would be appriciated

  2. #2
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi there,

    Have a look at the attached where once the input (yellow shaded) cells are entered and the user then clicks the List Files button, every file that matches the file (extention) type (B2) for the entered directory (B1) are listed from cell A3 onwards.

    HTH

    Robert
    Attached Files Attached Files

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Please Login or Register  to view this content.

  4. #4
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Hi jindon,

    This is very clever!! Just one thing, for large lists (i.e. say all *.txt files from the C drive) it bombed out - any ideas

    Well done.

    Robert

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    Quote Originally Posted by Trebor76
    Hi jindon,

    This is very clever!! Just one thing, for large lists (i.e. say all *.txt files from the C drive) it bombed out - any ideas

    Well done.

    Robert
    Probably, caused by Transpose Function.
    Add to Sub test()
    Please Login or Register  to view this content.
    Delete in GetAllFiles()
    Please Login or Register  to view this content.
    and change to
    Please Login or Register  to view this content.
    Then delete transpose function in ListAllFiles()
    Please Login or Register  to view this content.
    One this more
    change to Variant array
    Please Login or Register  to view this content.
    Last edited by jindon; 12-19-2007 at 10:38 PM.

  6. #6
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,565
    Must be me, but it's crashing. Would you mind re-posting the entire (amended) code?

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834
    If it still crahses, it may be other factor.
    Please Login or Register  to view this content.

+ 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