Ask Your Question

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(
            "", 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

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

kelsa gravatar image


use this as starting point

edit flag offensive delete link more


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


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

Seen: 38 times

Last updated: Jan 18