English
Ask Your Question
1

How do you close LibreOffice Calc from a macro?

asked 2013-01-30 20:57:53 +0200

Goody gravatar image

updated 2013-02-08 03:17:43 +0200

qubit gravatar image

I am writing a shell script that runs a macro on a specified document in LibreOffice Calc. After the macro is ran, I would like Libre to automatically close. However, if I try to kill Libre from the script, it just crashes and freezes up instead of closing, so I was wondering if it might be possible to just run some command at the end of the macro that would close LibreOffice.

I also tried running it in both headless and invisible mode, but I must've had a misunderstanding of what they do, because all they did was prevent any dialogue boxes from popping up instead of actually preventing Libre from pooping up. If it helps any here is the line from the shell that starts Libre, opens the file, and runs the macro:

  soffice "macro:///Standard.SaveCSV.Main" $1

All help is appreciated!

edit retag flag offensive close merge delete

4 answers

Sort by » oldest newest most voted
0

answered 2013-02-16 00:03:15 +0200

qubit gravatar image

(note to self: you can't use comments to resolve q's! :-)

If you've found a function that works for you, please describe it in an Answer to this question. If not, please file an enhancement bug and provide as much information as possible. The QA team will be happy to help you triage your feature request in the bugtracker.

If you do file an enhancement bug, please post a link to it in a comment below using the format "fdo#123456".

Thanks for the input -- this sounds like it would be a really good enhancement for LO!

edit flag offensive delete link more
1

answered 2013-02-01 20:32:48 +0200

Goody gravatar image

The particular systems that this script will go on will not have the wmctrl tool, so that's out. I need another way to gracefully shut down office. When I tried using killall to bring it down, the next time I'd start it up, it would want to do recovery mode, and I can't have that. Also, we don't need to worry about document saving because that is the point of this macro (sorry for not mentioning that earlier). This would be so much easier if there were some kind of close command in Basic.

edit flag offensive delete link more

Comments

Hi @Goody, Adding a close command to LibreBasic sounds like a fine idea. Please file an enhancement bug and provide as much information as possible. The QA team will be happy to help you triage your feature request in the bugtracker. Thanks!

qubit ( 2013-02-08 03:26:42 +0200 )edit
1

answered 2013-01-30 22:43:10 +0200

w_whalley gravatar image

You didn't mention your operating system, but I've done something on linux that may be adaptable. I kill all instances of openoffice (never tried on libreoffice) with a cron script and the wmctrl tool. You might start a bash script from your macro that does the same. You may need to detach it from the initiating process. It will kill all instances of openoffice.

export DISPLAY=:0  # may not be needed except with cron
until [ -z "$(pgrep soffice.bin)" ] #for all openoffice instances
do
/usr/bin/wmctrl -c openoffice 2> /dev/null #close all openoffice instances
done
/usr/bin/killall soffice.bin  #this line forces closed all docs left in an unclosed state, otherwise they pop up a save dialog.
edit flag offensive delete link more
0

answered 2013-01-31 23:49:32 +0200

Goody gravatar image

My OS is Red Hat Enterprises Linux 6. I will have to try to see if I can't get the above code to work. Thanks.

edit flag offensive delete link more
Login/Signup to Answer

Stats

Asked: 2013-01-30 20:57:53 +0200

Seen: 648 times

Last updated: Feb 16 '13