Gruppe
Dialog
Problem
Wie kann man Dateinamen aus einer UserForm-MultiSelect-Listbox auslesen und die zugehörigen Dateien nacheinander öffnen?
StandardModule: basMain
Sub CallForm()
frmFiles.Show
End Sub
ClassModule: frmFiles
Private Sub cmdOpen_Click()
Dim iCounter As Integer
For iCounter = 0 To lstFiles.ListCount - 1
If lstFiles.Selected(iCounter) Then
Workbooks.Open lstFiles.List(iCounter)
End If
Next iCounter
End Sub
Private Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim iCounter As Integer
With Application.FileSearch
.LookIn = Range("B1").Value
.FileType = msoFileTypeExcelWorkbooks
.Execute
For iCounter = 1 To .FoundFiles.Count
lstFiles.AddItem .FoundFiles(iCounter)
Next iCounter
End With
End Sub