axism
MIS
- May 17, 2005
- 58
Hi, I want to have a list box listing all files in a folder in my local computer. I have few pdf files and word documents in the folder. I want to be able to click on file in list box to open up that file. I am having problem generating the list box now. Can someone help please? Here's what I have on form_load:
Private Sub Form_Load()
Dim strFiles() As String
Dim intFileCount As Integer
Dim varName As Variant
Dim strName As String
strName = Dir("c:\reports\")
Do Until strName = ""
ReDim Preserve strFiles(intFileCount)
strFiles(intFileCount) = strName
strName = Dir
intFileCount = intFileCount + 1
Loop
For Each varName In strFiles
Me.lstForms.Additem varName
Next
End Sub
lstForms is the name of my list box and that's where the problem is right now. please help! thanks
Private Sub Form_Load()
Dim strFiles() As String
Dim intFileCount As Integer
Dim varName As Variant
Dim strName As String
strName = Dir("c:\reports\")
Do Until strName = ""
ReDim Preserve strFiles(intFileCount)
strFiles(intFileCount) = strName
strName = Dir
intFileCount = intFileCount + 1
Loop
For Each varName In strFiles
Me.lstForms.Additem varName
Next
End Sub
lstForms is the name of my list box and that's where the problem is right now. please help! thanks