Solved

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

Posted on 2010-11-24
1
584 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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
countX 22 69
Windows Command Line in Python 16 47
Currency Conversion? 1 34
Base1 Encode/Decode 3 21
When we want to run, execute or repeat a statement multiple times, a loop is necessary. This article covers the two types of loops in Python: the while loop and the for loop.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now