Results 1 to 3 of 3
  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Dallas plus 20 miles or so, Texas, USA
    Posts
    876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    List box contents

    Hi all,

    What would be the best way to populate the contents of a list box with the contents of a directory? I have looked at GetObject, Path, and Dir, but I am a little unsure which to start with.

    I would like to populate the list box with the directory contents, and then use the click event to open whichever file is clicked.

    Thanks,

  2. #2
    4 Star Lounger
    Join Date
    Jan 2001
    Location
    Kortrijk, Belgium
    Posts
    571
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List box contents

    Mike,

    I think there have been several posts on how to loop through a directory and find the names of the files in it; e.g. This post might help you. But I think that Legare has posted a somewhat more easy macro to do more or less the same. Anyhow, once you have the names of the files of a particular directory in an array, you can easily fill the listbox with the elements of that array, using somewhat similar to:
    <pre>For i = 1 to Ubound(FileArray)
    ListBox1. AddItem FileArray(i)
    Next i
    </pre>


  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Dallas plus 20 miles or so, Texas, USA
    Posts
    876
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: List box contents

    Thanks Hans, I will explore the post you sent.

Posting Permissions

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