First copy and paste the following function into a module..
Function FolderList(folderpath) As String
Dim fs, f, f1, fc, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderpath)
Set fc = f.SubFolders
For Each f1 In fc
s = s & f1.Name
s = s & ";"
Next
FolderList = Left(s, Len(s) - 1)
End Function
Now ensure your list box has its Row Source Type set to value list. Then
within the appropriate event procedure include the line...
Me.MyListBoxName.RowSource = FolderList("C:\")
Where "C:\" is the path to the required directory.
HTH
Sam
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.