使用xw.books就可以显示现在打开的所有Excel表
xw.books
# Books([<Book [Book1]>, <Book [Book2]>])
xw.apps[10559].books # specific app, get the PIDs via xw.apps.keys()
# Books([<Book [Book1]>, <Book [Book2]>])
activate可以切换操作焦点到Excel上,steal_focus默认为False,这样只会激活不会把其移到最上层窗口。
Book.fullname可以获得完整路径
filepath = sorted([i.fullname for i in xw.books ])[-1]
wb = xw.Book(filepath)
wb.activate(steal_focus=True)
同理xw.apps可以获得所有打开的Excel App。可以获得PID。