Need Help with COM

Stefan Schukat SSchukat at dspace.de
Wed Aug 15 02:48:43 EDT 2001


The object you are using is returing a parameter by reference. 
Since this is not supportted in Python MarkH uses tuples to 
return out values in COM calls. So in your case you should try
something like this: 

o.Application.ActiveMenuBar.Menus.Item(1)[0].Caption

to access the first return value which is probably your
object.


  Stefan Schukat


> "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
> 
> 
> 
> 
> 
> 
> 
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 




More information about the Python-list mailing list