+ Reply to Thread
Results 1 to 14 of 14

Want to show files from directory and sub directory too

  1. #1
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Want to show files from directory and sub directory too

    hello, everyone

    i am using below to get file from directory in listbox Userform

    Please Login or Register  to view this content.
    but i want show files from folders and subfolders too


    thanx
    Use Code-Tags for showing your code :
    Please mark your question Solved if there has been offered a solution that works fine for you
    If You like solutions provided by anyone, feel free to add reputation using STAR *

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Want to show files from directory and sub directory too

    Subfolders where exactly? What would be the new top starting directly into which you want to dive down from?
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Want to show files from directory and sub directory too

    Hello HaroonSid,

    Try this...

    Module Macro Code
    Please Login or Register  to view this content.
    UserForm Code
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Want to show files from directory and sub directory too

    How does this work out for you?

    Had to put it in textfile because site won't let me post wscript code.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Want to show files from directory and sub directory too

    Bakerman, the forum server does not like HTML being posted, and it probably thought that was what you were posting
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  6. #6
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Want to show files from directory and sub directory too

    OK Ford, thanks for clarifying.

  7. #7
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to show files from directory and sub directory too

    Thanx for the reply

    @Leith Ross
    i uploaded the sample workbook with yours code

    it getting mismatch error

    plz look here, what i am doing wrong
    Attached Files Attached Files

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Want to show files from directory and sub directory too

    You forgot to put in FileFilter.

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to show files from directory and sub directory too

    Thanx a lot bakerman2

    its working perfectly

    but i want little change in code.

    i don't want to show the file path only show file name in listbox

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Want to show files from directory and sub directory too

    Change this

    Please Login or Register  to view this content.
    to this

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to show files from directory and sub directory too

    thanx a lot Bakerman2 and Leith Ross

    thread closed

  12. #12
    Forum Contributor HaroonSid's Avatar
    Join Date
    02-28-2014
    Location
    india
    MS-Off Ver
    Excel 2013
    Posts
    2,080

    Re: Want to show files from directory and sub directory too

    sorry for disturb again

    but i want to open file which are showing in listbox with command button
    Last edited by HaroonSid; 02-03-2017 at 11:36 AM.

  13. #13
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Want to show files from directory and sub directory too

    Then taking out the full path was probably a mistake.

    Design suggestion: perhaps the routine actually compiles the complete list of files in a hidden sheet. Column A is the path to the file, Column B lists the found filename. Use column B to populate your Listbox. When a file is selected you will have column A still available to quickly get to the file itself.

    You will need to consider and resolve issues with files of the same name in more than one folder.

  14. #14
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Want to show files from directory and sub directory too

    Hello HaroonSid,

    Please try the Code below in a new Workbook. Maybe that is what you are after?

    Please Login or Register  to view this content.
    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

+ 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: 0
    Last Post: 09-05-2013, 10:00 AM
  2. Moving Files from one directory structure to another directory
    By harddd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-17-2013, 02:39 PM
  3. Macro to Move files from one directory to other directory
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-05-2013, 07:21 AM
  4. Need VBA code to search file in directory and sub-directory and show result
    By johnchencanada in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-19-2012, 11:13 PM
  5. Reading in the files in a directory into an array, directory chosen by user
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-18-2011, 12:52 PM
  6. Look into a directory for a zip, delete, and repeat until directory is empty.
    By HandL in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2008, 09:45 AM
  7. [SOLVED] macro to move from directory to directory
    By davegb in forum Excel General
    Replies: 20
    Last Post: 02-06-2005, 04:21 PM

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