[python-win32] can't set a property

Tim Roberts timr at probo.com
Wed Dec 9 20:21:40 CET 2009


John wrote:
> ...
> 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"
> ...
> Just for information the ItemName[0] is an array (I think not a Vb guy) of 
> items on a invoice.  ItemName[0] would refer to the first line item on the 
> invoice and ItemName[1] the second and ...
>   

Well, remember that ItemName is not really an array.  It's a function
that happens to look like an array to VB.

The Python COM support will usually provide Set and Get versions for
indexed properties.  Try this:
    obj.SetItemName( 0, 'String' )

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list