Sub test()
Dim wb1 As Workbook, wb2 As Workbook
Workbooks.Open "file1.xlsx"
Set wb1 = ActiveWorkbook 'The wb1 object is established in the active book (it is the recently opened book)
Set wb2 = ThisWorkbook 'It does not matter which book is active, in the object wb2 the book that contains this macro is established.
End Sub