Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

There is any DirList control in VBA 1

Status
Not open for further replies.

Gti

Programmer
Jul 23, 2001
99
PT
There is any DirList control for Vba?
Tkx
 
Yes, it is.

Copy codes of function ShowFolderList into any module, then create unbound listbox with one column on form and RowSourceType=Value List. Put into Form Load procedure this command:
Example
Private Sub Form_Load()
'List box will be show all folders on drive C:\
me.lstUnboundListBox.RowSource=ShowFolderList("C:\")
End sub


or

Private Sub Form_Load()
'List box will be show all subfolders of folder C:\MyFolder
me.lstUnboundListBox.RowSource=ShowFolderList("C:\MyFolder")
End sub


'----------------------------
Function ShowFolderList(FolderSpec As String) As String
'This function create text for folders listbox (one column)
Dim fs, f, f1, s, sf
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(FolderSpec)
Set sf = f.SubFolders
For Each f1 In sf
If s <> &quot;&quot; Then
s = s & &quot;;&quot;
End If
s = s & f1.Path
Next
ShowFolderList = s
End Function


Aivars
 
MS Access allows the use of the Windows Common Dialog Control. See help or search this form, Keyword &quot;Common Dialog&quot;.

This control allows you to do actions such as Open File and Save As. It also allows you to open the color and font dialog boxes.

ljprodev@yahoo.com
ProDev, MS Access Applications
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top