[python-win32] Problem passing a VARIANT argument to a method of a COM object

Sumeet Sobti sumeet_sobti at yahoo.com
Fri Feb 3 22:19:57 CET 2006


Hi everyone,

I am struggling with a problem related to passing a
VARIANT argument to a COM object.

I am getting this exception:

TypeError: The VARIANT type is unknown (0000001e)

Here's what I am trying to execute:

- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32
bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.
>>>
>>> import win32com.client
>>>
>>> obj =
win32com.client.Dispatch('XTAPI.TTOrderSelector')
>>>
>>> obj.AddTest('IsBuy', True)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File
"C:\Python24\lib\site-packages\win32com\gen_py\98B8AE14-466F-11D6-A27B-00B0D0F3CCA6x0x1x0.py",
line 609, in AddTest
    return self._oleobj_.InvokeTypes(4, LCID, 1, (24,
0), ((30, 1), (12, 1)),lpProperty, vValue)
TypeError: The VARIANT type is unknown (0000001e)
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -

The makepy generated code-snippet is this:

- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
	def AddTest(self, lpProperty=defaultNamedNotOptArg,
vValue=defaultNamedNotOptArg):
		"""method AddTest"""
		return self._oleobj_.InvokeTypes(4, LCID, 1, (24,
0), ((30, 1), (12, 1)),lpProperty, vValue)
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -

The AddTest method is documented to accept two
arguments: the first argument is a string and the
second is a variant. It returns nothing.

I am not able to pass anything as the second argument.
I have tried string, int, float,... but nothing gets
properly converted to variant,
and I get the same exception as above.

What does the above exception really mean? Regardless
of what I pass as the second argument, I get the same
exception message.
It just complains about unknown type 0000001e, which
probably corresponds to VT_LPSTR. But, why is it
trying to convert True to a VT_LPSTR?!

I'd really appreciate any ideas/help.

Thanks!

-Sumeet.


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


More information about the Python-win32 mailing list