Solved

Is it possible to run openoffice scripts from the command line?

Posted on 2010-11-24
1
592 Views
Last Modified: 2012-05-10
I installed the python uno libraries and am able to run the HelloWorld.py script from within Writer but I was wondering if it's possible to run these python scripts from the command line. I tried doing:
>python HelloWorld.py
but got no response or no error message. I figure that some code has to be added to connect with openoffice and tell it which document should be modified.
0
Comment
Question by:opike
1 Comment
 
LVL 2

Accepted Solution

by:
markoilic earned 500 total points
ID: 34206048
First  Open Office need to be started with following command:

x:\path_to_openOffince\program>soffice "-accept=socket,host=localhost,port=2002;urp;"

Then if you have installed uno package in python you can make conection with:

import uno
 
localContext = uno.getComponentContext()
resolver = localContext.ServiceManager.createInstanceWithContext(
                        "com.sun.star.bridge.UnoUrlResolver", localContext )
ctx = resolver.resolve( "uno:socket,host=localhost,port=2002;urp;StarOffice.ComponentContext" )
smgr = ctx.ServiceManager
desktop = smgr.createInstanceWithContext( "com.sun.star.frame.Desktop",ctx)
model = desktop.getCurrentComponent()
text = model.Text
cursor = text.createTextCursor()
text.insertString( cursor, "Hello World from command line", 0 )
ctx.ServiceManager


More on following link
http://wiki.services.openoffice.org/wiki/PyUNO_bridge
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
windows 10 bash shell 4 47
import 13 row from .csv file into another csv file 11 50
Delphi: barcode reading on android platform 1 30
SQL Insert parts by customer 12 34
This article will show, step by step, how to integrate R code into a R Sweave document
A short article about problems I had with the new location API and permissions in Marshmallow
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question