Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-11-24
1
Medium Priority
?
638 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Introduction to Processes

618 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