Here is the code:
Filt = "Excel Files (*.xlsx),*.xlsx,Excel Files (*.xls),*.xls"
FilterIndex = 5
Title = "File 1"
Filename = Application.GetOpenFilename(FileFilter:=Filt, _
FilterIndex:=FilterIndex, Title:=Title)
Workbooks.Open (FileName)
To get the file name
P = WorksheetFunction.Substitute(FileName, Left(FileName, InStrRev(FileName, "\")), "")
Filt = "Excel Files (*.xlsx),*.xlsx,Excel Files (*.xls),*.xls"
FilterIndex = 5
Title = "File 1"
Filename = Application.GetOpenFilename(FileFilter:=Filt, _
FilterIndex:=FilterIndex, Title:=Title)
Workbooks.Open (FileName)
To get the file name
P = WorksheetFunction.Substitute(FileName, Left(FileName, InStrRev(FileName, "\")), "")
No comments:
Post a Comment