Trying to use COM... "Type mismatch" error

Simon Withers spw105 at york.ac.uk
Fri May 9 05:58:50 EDT 2003


Mark Hammond <mhammond at skippinet.com.au> wrote in message news:<RKEua.6539$_o4.90224 at news-server.bigpond.net.au>...

> You should just be able to run makepy, then use win32com.client.Dispatch 
> as normal.  Evertthing should "just work" (but unfortunately doesn't for 
> some).
> 
> > com_error: (-2147352567, 'Exception occurred.', (0, 'TGLLib', 'Type
> > mismatch', None, 1000013, -2146828275)
> 
> This means that TGLLib itself threw an exception.  This often means that 
> you passed an incorrect type.
> 
> Can you post the complete interactive session, and the traceback.  Also 
> please include a "print repr(ob)" in the output, where "ob" is the COM 
> object you are trying to call.

Hi Mark,
Here's the interactive session...

>>> from win32com.client import Dispatch
>>> myTGL = Dispatch("TGLLib.TGLFile")
>>> print repr(myTGL)
<win32com.gen_py.22E8D31A-01EE-4EB1-9AED-07264C052957x0x25x0._TGLFile>
>>> myTGL.Filename="D:\myTGL.tgl"
>>> myTGL.Load()
>>> print repr(myTGL.Strings)
<win32com.gen_py.22E8D31A-01EE-4EB1-9AED-07264C052957x0x25x0._TGLStrings>
>>> myTGL.Strings.Lookup()
(None, u'')
>>> myTGL.Strings.Add(Name=u'Name', Data=u'This is my data',
Media=u'media.wav')
Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "D:\Python22\Lib\site-packages\win32com\gen_py\22E8D31A-01EE-4EB1-9AED-07264C052957x0x25x0.py",
line 65, in Add
    return self._ApplyTypes_(0x60030003, 1, (9, 0), ((16392, 3),
(16392, 3), (16392, 3), (16396, 19)), 'Add',
'{248731B8-8D33-4B18-9219-240086A375F6}',Name, Data, Media, Key)
  File "D:\Python22\Lib\site-packages\win32com\client\__init__.py",
line 341, in _ApplyTypes_
    return self._get_good_object_(apply(self._oleobj_.InvokeTypes,
(dispid, 0, wFlags, retType ,argTypes ) + args), user, resultCLSID)
com_error: (-2147352567, 'Exception occurred.', (0, 'TGLLib', 'Type
mismatch', None, 1000013, -2146828275), None)
>>>

Hope it sheds some light on things...

Simon




More information about the Python-list mailing list