Hello, I am using a call to a windows function via ctypes to retrieve a pointer to the IDispatch interface of an Excel application, something like:
oledll.oleacc.AccessibleObjectFromWindow(hnd, OBJID_NATIVEOM, byref(automation.IDispatch._iid_), byref(pointer_idispatch)) where hnd is the window handle to the proper excel window. In the variable result (with type POINTER(IUnknown)), I have the pointer to the interface. Currently, to be able to call methods/properties on this COM object, I call the "wrap" function from the comtypes.client library and then use the COM object, something like: app = wrap( pointer_idispatch ) print app.Application.Name '==> "Microsoft Excel" app.Application.ActiveWorkbook.ActiveSheet.Cells(1,1).Value[()] = 1 However, this is slow (a coupe of seconds to do the wrap) and the resulting object is less friendly to use than the COM object I can get with win32. For instance, i need to use app.Application.ActiveWorkbook.ActiveSheet.Cells(1,1).Value[()] = 1 instead of app.Application.ActiveWorkbook.ActiveSheet.Cells(1,1).Value = 1 So my question, how could I instantiate a COM IDispatch object from win32 (equivalent of 'app' hereabove) when I have the pointer to the IDispatch interface ('pointer_idispatch' hereabove) ? thank you Sebastien
_______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32