+ Reply to Thread
Results 1 to 10 of 10

List both files and folders in a directory

  1. #1
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    List both files and folders in a directory

    Is it possible to list both files and folders in a directory?
    Using the "FileSystemObject" method.

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: List both files and folders in a directory

    Something like this perhaps...
    Please Login or Register  to view this content.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Re: List both files and folders in a directory

    Quote Originally Posted by Un-Do Re-Do View Post
    Is it possible to list both files and folders in a directory?
    Using the "FileSystemObject" method.
    Yes but the more files & folders, the slower (than using Dir VBA function) …

  4. #4
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Re: List both files and folders in a directory

    @sintek, your code gives only folder or file. I needed both.
    For example, list in snapshot should be:

    New folder1
    New folder2
    New Microsoft Excel Worksheet1
    New Microsoft Word Document1


    Capture.JPG

  5. #5
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: List both files and folders in a directory

    So...You do not want the files within the subfolders of the folders...
    You just want first level Folders and files...

  6. #6
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Re: List both files and folders in a directory

    Yes I do want subfolders but that will come later.
    The hard part seems to be listing folders together with files.

  7. #7
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: List both files and folders in a directory

    Perhaps I just don't understand...
    If for example on your desktop you have 2 Folders and two documents...
    Must code show those 4 only....Not go in further

  8. #8
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Re: List both files and folders in a directory

    Yes, show 2 folders and 2 documents.
    Yes, go to subfolders where they exist.

  9. #9
    Forum Contributor
    Join Date
    11-10-2009
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    548

    Re: List both files and folders in a directory

    Harder than I thought.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: List both files and folders in a directory

    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)

Similar Threads

  1. Replies: 5
    Last Post: 11-02-2018, 03:15 AM
  2. [SOLVED] get list of folders in a directory
    By plans in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 09-30-2017, 05:16 PM
  3. [SOLVED] How to open all excel files within a directory of folders.
    By randomguy1 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-17-2013, 01:55 AM
  4. Code to set combo box to list folders in a directory
    By Kezwick in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-08-2013, 07:07 AM
  5. Copy matching files/folders (using unique ID) from one directory to another
    By TommyK25 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 06-10-2013, 06:38 AM
  6. Generate a list of folders within a directory
    By TRT7G7 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-17-2010, 11:24 AM
  7. List of folders in a certain directory
    By woolyhedgehog in forum Excel General
    Replies: 1
    Last Post: 10-19-2005, 12:05 PM

Tags for this Thread

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