I have the below code that works well, but need to modify it so that it starts within the same folder instead of the default of the My Documents folder.
Is there a way to have this open within the same folder?
I don't want to specify the file path. Rather use something like ThisWorkbook.Path
Please help.
Is there a way to have this open within the same folder?
I don't want to specify the file path. Rather use something like ThisWorkbook.Path
Please help.
VBA Code:
Dim FileToOpen As Variant
Dim FileName As String
Dim OpenBook As Workbook
Application.ScreenUpdating = False
FileToOpen = Application.GetOpenFilename(Title:="Browse for the file to Import", FileFilter:="Excel Files(*.xls*),*xls*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
Active.Worksheet.Unprotect
OpenBook.Sheets(1).Range("A1:E20").Copy
ThisWorkbook.Worksheets("Template").Range("A2").PasteSpecial xlPasteValues
OpenBook.Close False
End If
Application.ScreenUpdating = True