Reputation: 4577
Using win32com, I have two workbooks open.
Upvotes: 2
Views: 3310
Reputation: 108537
What is your larger goal here? Automate already open excel windows or simply write XLS files? If it's the latter you should use consider using xlwt.
How do you know which one is active?
xl = win32com.client.Dispatch("Excel.Application")
wbOne = xl.Workbooks.Add()
wbTwo = xl.Workbooks.Add()
xl.ActiveWorkbook == wbOne
False
xl.ActiveWorkbook == wbTwo
True
How do you change which one is active?
wbOne.Activate()
xl.ActiveWorkbook == wbOne
True
How can you close one and not the other? (not Application.Quit())
wbOne.Close()
wbTwo.Close()
Upvotes: 6