Need Help with COM
Michael A. Howard
mhoward at mahoward.com
Wed Aug 15 18:29:20 CEST 2001
Thanks, that resolved the problem.
"Stefan Schukat" <SSchukat at dspace.de> wrote in message
news:mailman.997854502.16411.python-list at python.org...
> 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:
> to access the first return value which is probably your
> 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