Forum Discussion

Lorenzo Kim's avatar
Lorenzo Kim
Bronze Contributor
Aug 08, 2018
Solved

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 ...
  • Philip West's avatar
    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..

Resources