List box

  • Thread starter Thread starter Bill
  • Start date Start date
Well fairly simple!

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
 
Back
Top