+ Reply to Thread
Results 1 to 4 of 4

Add files to a ListBox from a User defind folder

  1. #1
    Registered User
    Join Date
    11-14-2012
    Location
    Lebanon, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    47

    Add files to a ListBox from a User defind folder

    I am trying to create a user form that will list all the vendor folders, sub folders and files. I have already created a button that allows the user to pcik the vendor folder location, there is also a TextBox linked to the Browse button that shows the folder file path.
    The problem I am having is getting the Mfg folders, sub folders and files listed in my ListBox.

    What I am trying to do would look something like this

    J:\Shared\Engineering\Electrical\Vendor Info <<<<Vendor folder path

    Vendor Info <<<<Main folder
    --------------AB <<<<Mfg folder
    ---------------------1492-IFM <<<<Sub folder
    ----------------------------1492-IFM20F_MULTIPLE.pdf <<<<File
    --------------20-COMM-E Ethernet IP Adapter.pdf <<<<File
    --------------ABB <<<<Mfg folder
    ---------------------Circuit Breakers <<<<Sub folder
    ----------------------------TMAX Series <<<<Sub folder
    ------------------------------------TMAX frames sizes 1-8.pdf <<<<File

    This would be in "ListBox1" the user then could select the desired files click the move files to "ListBox2" button.
    everyting in "listBox2" could then be copied out to a second user defind location once the user submits their file selection.

    Here is what I have so far.
    Vendor list.xlsm

    I have been looking for an answer but have not been able to find anything.

    Thank you for the help.
    Last edited by klonbeck; 11-16-2012 at 07:02 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Add files to a ListBox from a User defind folder

    Attached is the part of your solution that populates the source listbox. [klonbeck=populate listbox with directory tree=Vendor list.xlsm] I added a button to bring the form up.

    Note that I removed your scrollbars. A listbox has built-in scroll bars. I also set the ColumnWidths value to 1000 to force a horizontal scrollbar.

    The list algorithm lists the folder name, then under it lists each subfolder and then the files. Under each subfolder, it lists those subfolders and then the files, and so on recursively.

    You have a bit more work to do. I suggest using a second hidden column in the listbox to store the full path name of each file. You will have to figure out how to allow the user to only move files to the right side, and then how to actually perform the file move.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    11-14-2012
    Location
    Lebanon, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: Add files to a ListBox from a User defind folder

    Thank you 6StringJazzer!!

    My VBA code knowledge is purty weak, I dont think I could have figured this out with out help.

    do you know of a good VBAuser manual that I could get my hands on? As you said I have a lot more to do on this code before it is finished.

    Again thank you very much for the help.

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Add files to a ListBox from a User defind folder

    I learned VBA from a book by John Walkenbach, and I recommend his work highly. There is a huge amount of material available free online but it is mostly good for reference; I don't know of an online tutorial for beginners.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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