Hi ~ ALL
This vba can Open the Files with multiselect function and the files path will show in the listbox. Also, it can delete the single file path in list box.
[VBA]
? Multi-select the file(s) and list in the listbox1
Private Sub cmdInput_Click()
Dim Files As Variant
Dim sFileShort As String
Dim i As Long
Dim Title As String
Dim Finfo As String
Dim Msg As String
' Setup lists of file filters
Finfo = "Exceld Files (*.xls),*.xls,"
' Set the dialog box caption
Title = "select a File to Import"
Files = Application.GetOpenFilename(Finfo, , Title, MultiSelect:=True)
' Exit if dialog box canceled
If Not IsArray(Files) Then
MsgBox "No file was selected."
Exit Sub
End If
'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
' Delete the single file
Private Sub cmdDelete_Click()
Me.ListBox1.RemoveItem (Me.ListBox1.ListIndex)
End Sub[/VBA]
Then, i try to modify it with the Multi-Delete function. Although it can multi-select the files in listbox, the action stills delete single file when i click the delete button.
[VBA]
With Me.ListBox1
.MultiSelect = 2
.AddItem sFileShort
.List(.ListCount - 1, 1) = Files(i)
End With
[/VBA]
Therefore, how to modify it with multi-delete function. Thanks