[Tutor] Open a libreoffice calc file in Python
jf_byrnes at comcast.net
Thu Dec 22 13:12:13 EST 2016
On 12/22/2016 03:54 AM, Alan Gauld via Tutor wrote:
> On 22/12/16 03:37, Jim Byrnes wrote:
>> Python 3.4 on Ubuntu
>> If I was going to open a libreoffice calc file from the terminal I would
>> go: libreoffice --calc /home/path/to/myfile.ods.
>> How would I do this from Python?
> Others have advised how to run the Libreoffice app from
> within Python.
> If you really want to open the actual spreadsheet file
> in Python rather than Libreoffice then its a bit more tricky.
> If that is what you really meant get back to us and
> we can start on the options available...
First thanks to everyone that responded pointing me in the right direction.
I want to open Libreoffice with a particular file loaded.
I started out to write a libreoffice macro in python to go to a website,
get some info, copy it to the clipboard and then paste it in libreoffice
I started out by writing a script using Selenium that successfully did
what I wanted. Once I had it working the plan was to put it in a macro.
When I did that I got a large error message where both libreoffice and
selenium complained. I seemed to say that the first element of the
webpage I tried to manipulate was in a state that it could not be
interacted with, even though outside of libreoffice the script ran fine.
This got me thinking that maybe I should attack the problem from the
other end, ie run the script and have it load libreoffice at the end.
Hence my question.
for completeness here is the error msg I received:
com.sun.star.uno.RuntimeExceptionError during invoking function login in
Message: invalid element state: Element is not currently interactable
and may not be manipulated
(Session info: chrome=55.0.2883.87)
(Driver info: chromedriver=2.25.426924
in function check_response() [raise exception_class(message, screen,
in function execute() [self.error_handler.check_response(response)]
in function _execute() [return self._parent.execute(command, params)]
in function clear() [self._execute(Command.CLEAR_ELEMENT)]
in function login() [username.clear()]
/usr/lib/libreoffice/program/pythonscript.py:869 in function invoke()
[ret = self.func( *args )]
More information about the Tutor