[python-win32] Using win32com.client.GetActiveObject to attach to a specific running Excel application

Marcus Valentine marcus at marcusv.org
Wed Oct 19 08:43:39 EDT 2016


I have a question related to "Attach to a running instance of a COM
application" at

http://timgolden.me.uk/python/win32_how_do_i/attach-to-a-com-instance.html

In my application, I end up with several instances of Excel open, for
example, inspecting the Running Object Table as described at

http://timgolden.me.uk/python/win32_how_do_i/see-if-an-excel-workbook-is-open.html

I can see

12:39:09 PM - INFO - ROT: Found my_results2
12:39:09 PM - INFO - ROT: Found my_results3
12:39:09 PM - INFO - ROT: Found my_results1

When I do

xl = win32com.client.GetActiveObject ("Excel.Application")

Is there a way of selecting which one of found Excel applications I
attach to (the one with the highest number, which was created most
recently)?

Thanks

Marcus Valentine


More information about the python-win32 mailing list