win32com: how to connect to a specific instance of a running object?

ago xivulon at gmail.com
Fri Jun 2 09:17:50 EDT 2006


Thanks, after some further digging I hit something...
The following seems to do the trick:

import win32gui
WINDOW_CLASS = 'XLMAIN'
WINDOW_TITLE = 'Microsoft Excel - MySpreadsheet.xls'
hwindow = win32gui.FindWindow(WINDOW_CLASS,WINDOW_TITLE)

Now the next question is: how do I use the window-handle returned? I
would like to work with a com object like the one returned by
win32com.client.Dispatch('ExcelApplication'). Any hint?

PS I could also use win32ui instead win32gui, in this case I get a
window object instead of an handle. But I still do not know how to
transform it into a nice pythoncom excel object.




More information about the Python-list mailing list