win32com - .ocx won't Dispatch...

RJ rays at san.rr.com
Thu Jan 29 04:04:22 CET 2004


Hi,
I've been going over the Quick Start to Client side COM and Python and many 
other sources, but cannot find an example that will get my com/ActiveX .ocx 
USB device driver imported.

The Excel and Word examples run fine.
win32com.client.Dispatch("Excel.Application") etc., but how does one know 
the ("<foo>.<bar>") to type in? Excel looks only vaguely like 
"Excel.Application" in the com browser.

Firstly, I found the ocx from the Python Object Browser.
I ran makepy.py on EDREUtlX.ocx (USB device driver) which created
8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5.py
etc. in gen_py\,
but, I cannot find a syntax to get Dispatch to accept it...

from win32com.client import Dispatch
# failed attempts
Dispatch("EDRE Utility Control") # name in browser
Dispatch('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5}')
Dispatch('{8AA34F82-95C9-11D3-8EB6-00C0DF2247CA}')
Dispatch("8AA34F82-95C9-11D3-8EB6-00C0DF2247CA")
Dispatch("8AA34F82-95C9-11D3-8EB6-00C0DF2247CAx0x3x5")

all return:
Traceback (most recent call last):
   File "<stdin>", line 1, in ?
   File "C:\Python23\lib\site-packages\win32com\client\__init__.py", line 
95, in Dispatch
     dispatch, userName = 
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
   File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line 
84, in _GetGoodDispatchAndUserName
     return (_GetGoodDispatch(IDispatch, clsctx), userName)
   File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line 
72, in _GetGoodDispatch
     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, 
pythoncom.IID_IDispatch)
pywintypes.com_error: (-2147221005, 'Invalid class string', None, None)

So, what is the required syntax?

Thanks,
Ray





More information about the Python-list mailing list