win32com typelib difficulty

Paul McGuire ptmcg at austin.rr._bogus_.com
Mon May 24 15:56:28 EDT 2004


Software versions:
Python - 2.3.3
win32all extensions - build 163
OS- Win2000 SP4

I am having trouble in accessing a customer's proprietary COM type library.
After running makepy against the customer's typelib, I am still unable to
create a typed object, getting the following Python traceback (I have to
sanitize the customer's product, I have replaced it with XYZ):

Python 2.3.3 (#51, Dec 18 2003, 20:22:39) [MSC v.1200 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
>>> xyz = win32com.client.Dispatch("XYZApp")
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: (-2147467262, 'No such interface supported', None,
None)
>>> xyz = win32com.client.Dispatch("XYZ")
>>> xyz
<COMObject XYZ>
>>> xyz._print_details_()
AxDispatch container XYZ
Methods:
Props:
Get Props:
Put Props:
>>>


If xyz is a <COMObject XYZ>, how do I invoke methods on it?  I've already
tried the straightforward xyz.method1() call, and in this case I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "C:\Python23\lib\site-packages\win32com\client\dynamic.py", line 477,
in __getattr__
    raise AttributeError, "%s.%s" % (self._username_, attr)
AttributeError: XYZ.method1

although I know that method1() is defined for this interface.


Any other suggestions on how to proceed with this TLB?  I *really* want to
be able to write test scripts in Python, not in VB.

-- Paul







More information about the Python-list mailing list