Reputation: 369
I would like to switch to another already opened Excel book. My scenario:
xw.Book()
xw.books.active
The output:
<Book [Book7]>
xw.Book()
xw.books.active
The ouput: <Book [Book8]>
xw.books["Book7"]
xw.books.active
But it outputs:
<Book [Book8]>
!!!
How could I reactivate previous book (Book7)? Thank you:-)
Upvotes: 1
Views: 856
Reputation: 7070
Assign your new workkbok to a variable, then use the activate
method on it, see: https://docs.xlwings.org/en/stable/api.html#xlwings.Book.activate.
book1 = xw.Book()
book2 = xw.Book()
book1.activate(steal_focus=True)
Up to you if you want steal_focus
to be True
or False
(default).
Upvotes: 2