Ask Your Question
0

python script connect to writer document

asked 2019-01-17 23:34:23 +0100

carnish gravatar image

Using python and uno I want to connect to an open document and, for example, save it.

The following code connects to libreoffice, but I don't know how to connect to the file I have open in writer. Anyone know what comes next?

import uno
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
            "com.sun.star.bridge.UnoUrlResolver", localContext )

# connect to the running office
ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2019-01-18 00:09:49 +0100

kelsa gravatar image

Hi,

use this as starting point https://github.com/kelsa-pi/PyUNO_Wor...

edit flag offensive delete link more

Comments

This post may also be of help -> Python IDE Basics

Ratslinger gravatar imageRatslinger ( 2019-01-23 18:25:16 +0100 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-01-17 23:34:23 +0100

Seen: 38 times

Last updated: Jan 18