[Tutor] Re: Getting started with COM

Christian Junker christian at treesforlife.org
Sun Jun 13 04:20:31 EDT 2004

Doh, you made me curious about whether it is possible to connect via COM to
UNO with Python, and yes it is!
I claim to know that there is no information about how to do that with
Python (especially), but it might be useful that you read documentation
about the Automation Bridge:

What I did is easily use the lines you write in VB for Python and it
absolutely worked:

The following example will open a new writer document of OOo:
>>> from win32com.client.dynamic import Dispatch
>>> server = Dispatch('com.sun.star.ServiceManager')
>>> odesktop = server.CreateInstance('com.sun.star.frame.Desktop')
>>> odesktop.loadComponentfromURL('private:factory/swriter', '_blank', 0,
list is the equivalent to an array type of UNO.

Now it should be easy for you to figure out how to export something to pdf,
I would just read how you do it with Starbasic (OOo's own scripting
language) and then translate it into Python (as you saw in my example it's
actually a very simple translation of how you would do it with Starbasic,


"John Fusco" <fusco_john at yahoo.com> wrote in message
news:20040613022421.44284.qmail at web52210.mail.yahoo.com...
> I am not a windows programmer, but I am interested in
> using Python to script some tasks on my Windows
> workstation.
> Reading the Python win32com documentation is not
> encouraging.  In one section where it discusses the
> specific attributes of COM objects it states "you are
> just expected to know".
> One thing I'd like to do is use OpenOffice to convert
> a document to PDF.  I know how to do this with the
> mouse, but how do I script it with COM.
> I used the COM browser to look for OpenOffice or
> Soffice objects and I found some, but that's all I
> know about them.  I checked the OpenOffice.org website
> and searched for COM and found nothing.
> Is this really so difficult?  How do I get started?
> Thanks in advance.
> John
> __________________________________
> Do you Yahoo!?
> Friends.  Fun.  Try the all-new Yahoo! Messenger.
> http://messenger.yahoo.com/
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor

More information about the Tutor mailing list