Listing contents of a directory in a listbox

  • Thread starter Thread starter SpinifeX
  • Start date Start date
S

SpinifeX

Hi, i need to know how to list the files in a directory in a listbox, but i
am unsure how, any help would be greatly appreciated.
 
Set the List Box's RowSourceType to 'Value List' then in the forms 'OnLoad'
event use:

Set fs = CreateObject("Scripting.filesystemobject")
Set f = fs.getfolder("path to your folder with a trailing \")
Set fc = f.files
For Each fl In fc
strng = strng & fl.name & ";"
Next
Me.[List Box Name].Rowsource = strng

That should do it.
 
Back
Top