[python-win32] OpenOffice automation
Raymond Yee
yee@uclink.berkeley.edu
Thu, 09 May 2002 23:52:13 -0700
Thanks, Mark, for walking me through this. OK -- I think I get it now. I'm in
the process of looking for a type library for OpenOffice but have not succeeded
yet. What if there is no available type library? Am I then out of luck in
terms of using Pythoncom to access OpenOffice?
I've had luck using Perl and VB to access OpenOffice. Is the reason I'm able
to use those COM client implementations that through the syntax of those
implementations, I'm able to clear indicate that createInstance is a *method*
and not a *property*?
For example, in Perl Win32::OLE, the following works::
$objDesktop = $objServiceManager->createInstance("com.sun.star.frame.Desktop");
If I wanted to access createInstance -- the *property*, I would write:
$objDesktop = $objServiceManager->createInstance;
Is there a way with pythoncom but having no access to any type library to say
"I know it's a method and not a property, don't try to access the property --
just go for the method"?
-Raymond
Mark Hammond wrote:
> > Please clarify. We typed
> >
> > objDesktop =
> > objServiceManager.createInstance("com.sun.star.frame.Desktop")
> >
> > Isn't the syntax we used calling the *method* creatInstance with
> > the parameter
> > "com.sun.star.frame.Desktop" of objServiceManager -- not the property?
>
> Exactly, and this is why we have a problem ;)
>
> In Python, foo.bar() will result in:
> * get attribute "bar" from object "foo"
> * call it.
>
> In "normal" Python:
>
> object.methodName
>
> will return a function object. 'object.methodName()' gets the function
> object as a property, then calls it.
>
> Unfortunately, this is also the way things work for pythoncom - obj.foo()
> first asks the object for a property named "foo", then attempts to call it.
> win32com.client intercepts this, and if it sees what it believes to be a
> method, it returns a method object. But if the attempt to reference the
> object proeprty succeeded, then it assumes the property reference is valid.
>
> makepy would solve this, but I am assuming you can not run makepy over this
> object. If the star office framework does have a type library, then run
> makepy over it and it should work.
>
> Mark.