Solved

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

Posted on 2010-11-24
1
599 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Make the most of your online learning experience.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Progress

691 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