Get the selected file name in a file open dialog
Sub GetImportFileName()
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")
If Filename = False Then
MsgBox "No file was selected."
Exit Sub
End If
Debug.Print Filename
End Sub
Related examples in the same category