English

How do you close LibreOffice Calc from a macro?

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 close delete 4 Answers Sort by » oldest newest most voted answered 2013-02-16 00:03:15 +0100 (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! more answered 2013-02-01 20:32:48 +0100 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. 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! ( 2013-02-08 03:26:42 +0100 )edit answered 2013-01-30 22:43:10 +0100 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.

more

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.

more