Forum Discussion
Lorenzo Kim
Aug 08, 2018Bronze Contributor
dialog box to open at active path
In the snippet below - how do I make the dialog box open at the active path or where the workbook was opened. many many thanks Dim strFileToOpen As String *** vba to declare the active path ...
- Aug 08, 2018
Dim strFileToOpen As String
ChDrive Left(ActiveWorkbook.Path, 1)
ChDir ActiveWorkbook.Path
strFileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", FileFilter:="Excel Files *.xls* (*.xls*),")
Workbooks.Open Filename:=strFileToOpen
Set targetedWB = Workbooks.Open(strFileToOpen)This should do it I think.. If you know the drive letter will be the same every time then you can replace that left() with just the letter..
Philip West
Aug 08, 2018Iron Contributor
Dim strFileToOpen As String
ChDrive Left(ActiveWorkbook.Path, 1)
ChDir ActiveWorkbook.Path
strFileToOpen = Application.GetOpenFilename _
(Title:="Please choose a file to open", FileFilter:="Excel Files *.xls* (*.xls*),")
Workbooks.Open Filename:=strFileToOpen
Set targetedWB = Workbooks.Open(strFileToOpen)
This should do it I think.. If you know the drive letter will be the same every time then you can replace that left() with just the letter..
- Lorenzo KimAug 08, 2018Bronze ContributorMr. West
It worked perfectly!!
Thank you very much.