[Tutor] win32com and ocx with properties

John jfabiani at yolo.com
Wed Dec 9 17:33:38 CET 2009


I realize that some may consider this an advance question.  But there are many 
here that are advance.  So I'm hoping some nice soul will help me.

I'm attempting to use a OCX designed to talk with QuickBooks.  I'm using 
win32com for the first time and have discovered an issue that I'm sure others 
have run into.  But researching google etc.  has not helped.

obj = win32com.client.Dispatch("InQB.Invoice.1")
#In the VB code 
#obj.ItemName(0) = 'string' 

#in python I'm trying 
obj.ItemName[0] = 'string'
#error is "Instancemethod object does not support item assignment"

I found and ran makepy.py and here is the code it created dealing with my obj.

# The method ItemName is actually a property, but must be used as a method
to correctly pass the arguments
def ItemName(self, ItemIndex=defaultNamedNotOptArg):
        """Line item property: Reference to the kind of item."""
        # Result is a Unicode object
        return self._oleobj_.InvokeTypes(19, LCID, 2, (8, 0), 
((3,1),),ItemIndex )

As I read the above code it can only return a string not assign anything. I'm 
not sure what "InvokeTypes" does.

So the question is how can I get around this issue?  I'm sure others need to 
set properties in com objects.

BTW does anyone know of a win32com forum or list?

Johnf



More information about the Tutor mailing list