Need Help with COM

Michael A. Howard mhoward at mahoward.com
Tue Aug 14 20:21:40 EDT 2001


"Mark_Pryor" <erlangen72 at hotmail.com> wrote in message
news:sVie7.10397$ZM2.950970 at newsread2.prod.itd.earthlink.net...
Hi,
Michael A. Howard wrote in message <9lc9t0$fo4$1 at news.apple.com>...
>I'm coming to Python from VB and trying to understand how the COM stuff
>works.
>
>I have a COM server (not written by me) that supports in VB the call
>oAppPC.AppItem.Properties.Item(1).Caption
>Which returns the caption of this item as I can see it from the object
>browser in VB
>
>The same call in python returns:
>Traceback (most recent call last):
>  File "<interactive input>", line 1, in ?
>AttributeError: 'tuple' object has no attribute 'Caption'
>
>If I use Excel as an example i.e.
>o.Application.ActiveMenuBar.Menus.Item(1).Caption
>I get   u'&File'
>Which is also what I get in VB (well &File anyway)
>
>So what am I doing wrong?

Thanks for the response but I get the same error message using that example.

Unfortunately the COM object is a black box (no source) to me so I can't
change it.

Mike

Either write the call like this (to handle the tuple):
( junk, mycap ) = oAppPC.AppItem.Properties.Item(1).Caption

or redesign the Item method to pass the index by value!
You might have to switch the vars above.

hth,
Mark Pryor
pgp KeyID: 0x1A966EC5










More information about the Python-list mailing list