Ann_BBO
07-22-2007, 08:19 PM
This vba can Open the Files with multiselect function and the files path will show in the listbox. it can open each file paths by clicking the "run" button
'Display full path and name of the files
For i = LBound(Files) To UBound(Files)
FileShort = Right(Files(i), Len(Files(i)))
With Me.ListBox1
.AddItem sFileShort
.List(.ListCount - 1, 1) = Files(i)
End With
Next i
End Sub
Private Sub cmdRun_Click()
Workbooks.Open Filename:=Me.ListBox1.List(Me.ListBox1.ListIndex)
End Sub
Now, i want to open all files in the listbox at once and user do not need to click the filelist in listbox. How to modify the above vba. I am try to modify the vba to below:
Private Sub cmdRun_Click()
Do Until ListIndex = -1
Workbooks.Open Filename:=Me.ListBox1.List(Me.ListBox1.ListIndex)
With ListBox1
.ListIndex = .ListIndex + 1
End With
Loop
End Sub
Although it can open the all files, it will show the error and user need select the first filelist in listbox.
Thanks
'Display full path and name of the files
For i = LBound(Files) To UBound(Files)
FileShort = Right(Files(i), Len(Files(i)))
With Me.ListBox1
.AddItem sFileShort
.List(.ListCount - 1, 1) = Files(i)
End With
Next i
End Sub
Private Sub cmdRun_Click()
Workbooks.Open Filename:=Me.ListBox1.List(Me.ListBox1.ListIndex)
End Sub
Now, i want to open all files in the listbox at once and user do not need to click the filelist in listbox. How to modify the above vba. I am try to modify the vba to below:
Private Sub cmdRun_Click()
Do Until ListIndex = -1
Workbooks.Open Filename:=Me.ListBox1.List(Me.ListBox1.ListIndex)
With ListBox1
.ListIndex = .ListIndex + 1
End With
Loop
End Sub
Although it can open the all files, it will show the error and user need select the first filelist in listbox.
Thanks