sobota, sierpnia 07, 2004

UNO Open Office

Doh, you made me curious about whether it is possible to connect via COM toUNO with Python, and yes it is!I claim to know that there is no information about how to do that withPython (especially), but it might be useful that you read documentationabout the Automation Bridge:http://udk.openoffice.org/common/man/tutorial/office_automation.htmlWhat I did is easily use the lines you write in VB for Python and itabsolutely 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 scriptinglanguage) and then translate it into Python (as you saw in my example it'sactually a very simple translation of how you would do it with Starbasic,VB).

2 komentarze:

Anonimowy pisze...

Just blogging for a while, found your site that also happens to be around web hosting server, so just saying what's up.

Charles

Natalia Zimniewicz pisze...

Bardzo fajnie napisane. Pozdrawiam serdecznie !