S
Steve C
I'm creating a user form with two list boxes. The list box on the left
(lstDivisions)has check boxes for Divisions (i.e., 01, 02, 03 etc.). Upon
selecting the desired division, I'd like the right list box (lstAvailDocs) to
display all the names of Word documents that exist in the corresponding
folder number located at G:\Master Specifications. For example, if the user
chooses division 02 on the left, then the right list box should display all
Word documents in G:\Master Specifications\02. The desired 02 folder may
contain other non-Word files, but I only want Word documents to display in
the second list box.
I made a start with the code below, but I need help with the details. Thanks!
-- Steve C
Private Sub lstbxDivisions_Change()
'Runs when a check box in Divisions list box is selected
For x = 0 To lstbxDivisions.ListCount - 1
If lstbxDivisions.Selected(x) = True Then
LastSelected = lstbxDivisions.List(x) 'Check box has been selected
'Following populates the AvailDocs list box with choices made in
lstbxDivisions
With lstbxAvailDocs
Ifile = FreeFile
Open "G:\Master Specifications\" & LastSelected For Input As #Ifile
While Not EOF(Ifile)
Line Input #Ifile, SpecName
.AddItem SpecName
Wend
Close #Ifile
End With
Next x
End Sub
(lstDivisions)has check boxes for Divisions (i.e., 01, 02, 03 etc.). Upon
selecting the desired division, I'd like the right list box (lstAvailDocs) to
display all the names of Word documents that exist in the corresponding
folder number located at G:\Master Specifications. For example, if the user
chooses division 02 on the left, then the right list box should display all
Word documents in G:\Master Specifications\02. The desired 02 folder may
contain other non-Word files, but I only want Word documents to display in
the second list box.
I made a start with the code below, but I need help with the details. Thanks!
-- Steve C
Private Sub lstbxDivisions_Change()
'Runs when a check box in Divisions list box is selected
For x = 0 To lstbxDivisions.ListCount - 1
If lstbxDivisions.Selected(x) = True Then
LastSelected = lstbxDivisions.List(x) 'Check box has been selected
'Following populates the AvailDocs list box with choices made in
lstbxDivisions
With lstbxAvailDocs
Ifile = FreeFile
Open "G:\Master Specifications\" & LastSelected For Input As #Ifile
While Not EOF(Ifile)
Line Input #Ifile, SpecName
.AddItem SpecName
Wend
Close #Ifile
End With
Next x
End Sub