Help with Python COM Type Mismatch

Markus Wankus markus_wankus at hotmail.com
Fri Dec 13 13:57:54 EST 2002


Well, I received a lot of help from Mark on this one, and finally have 
figured things out.  If anyone is interested, let me know and I will 
share my experiences.

Thanks again, Mark!
--
Markus.

Markus Wankus wrote:
> Hello all,
> 
> I am having some problems with some methods in an application I am 
> talking to through pythoncom, and I was wondering if anyone here was an 
> expert and could perhaps give me a list of things to try (as I am not 
> familiar with COM).
> 
> I am using the gencache.EnsureModule() with the CSLID makepy gave me for 
> my application.  I connected to my app fine, and called a couple methods 
> without any problems.  However, the third method I tried to execute has 
> the following prototype:
> 
> retval = object.Method(filename, filetype, &Error)
> 
> Where filename is a string, filetype is a long integer, and Error is an 
> output (long) indicating a variable to hold the error code of the method.
> 
> If I call it as follows:
> 
> a, b = Method(filename, filetype)
> 
> ...it tells me The last argument is not optional.
> 
> If I call it as follows:
> 
> a = Method(filename, filetype, var)
> 
> No matter what I pass into var (I have tried pythoncom.Empty) I get an 
> exception with a 'Type mismatch' on the last argument.  Is this common?  
> Is there a set bunch of steps to try to get around this problem?  BTW - 
> pythoncom.Missing gives me the 'argument is not optional' message.  
> Also, certain objects (like dictionaries) give me a message that the 
> argument could not be converted to COM VARIANT, so it is obviously 
> trying to do a conversion.
> 
> As a side note, I still have methods with no arguments which I must call 
> without brackets.  For example:
> 
> object.GetPathName() retuns an error saying 'unicode value is not 
> callable', but if I just use object.GetPathName it works fine (executes 
> the method and returns a string).  I thought the gencache and early 
> bindings were supposed to fix this issue as well?
> 
> Anyway, I am a bit lost as I have never used COM before.  Any help 
> anyone could provide would be greatly appreciated.
> 
> Thanks,




More information about the Python-list mailing list