Use filter in Open file dialog
Sub GetImportFileName2()
Filt = "Text Files (*.txt),*.txt," & "Lotus Files (*.prn),*.prn," & "Comma Separated Files (*.csv),*.csv," & "ASCII Files (*.asc),*.asc," & "All Files (*.*),*.*"
FilterIndex = 5
Filename = Application.GetOpenFilename (FileFilter:=Filt, FilterIndex:=FilterIndex, Title:="Select a File to Import",MultiSelect:=True)
If Not IsArray(Filename) Then
MsgBox "No file was selected."
Exit Sub
End If
For i = LBound(Filename) To UBound(Filename)
Debug.Print Filename(i)
Next i
End Sub
Related examples in the same category