Reputation: 69
Below is what I have but I get an error
Compile Error: Expected end of statement.
Set galreqws = Workbooks.Open FileName:=ThisWorkbook.Path & "\galreq.xlsx"
Upvotes: 0
Views: 676
Reputation:
If you are setting a var to the result of the Workbooks.Open method, bracket your parameters.
dim galreqws as workbook 'could also be dim galreqws as object
Set galreqws = Workbooks.Open(FileName:=ThisWorkbook.Path & "\galreq.xlsx")
'alternate
with Workbooks.Open(FileName:=ThisWorkbook.Path & "\galreq.xlsx")
debug.print .name
debug.print .fullname
debug.print .worksheets(1).name
'work with galreq.xlsx here
end with
If you are not setting an object var then leave the brackets out.
Workbooks.Open FileName:=ThisWorkbook.Path & "\galreq.xlsx"
Upvotes: 1
Reputation: 96753
No space after This:
Sub qwerty()
Workbooks.Open Filename:=ThisWorkbook.Path & "\qwerty.xlsm"
Set galreqws = ActiveWorkbook
End Sub
basically replace:
This workbook.Path
with:
ThisWorkbook.Path
(I use two lines of code to avoid confusing myself)
Upvotes: 0