[python-win32] OpenOffice automation

Mark Hammond mhammond@skippinet.com.au
Fri, 10 May 2002 15:44:54 +1000


> 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.