Ask Your Question
0

soffice won't run .ods file with macro from command line

asked 2017-11-11 20:54:10 +0100

Herb40 gravatar image

updated 2017-11-12 05:09:06 +0100

I am a new LO user trying to move from OO, and need to start LO Calc from Windows 10 .cmd files.

After a cd to C:\Program Files\LibreOffice 5\program, I've tried the following soffice commands with the indicated results:

soffice --help

This command works correctly and displays all of the soffice options in a window.

soffice --calc

This command works correctly and creates an empty spreadsheet.

soffice --norestore --nodefault path_to_my_.ods_file

This command fails and displays the message "C:\Program Files\LibreOffice 5\LibreOffice does not exist". The complaint is true since there is no LibreOffice file in the LibreOffice 5 directory. The path_to_my_.ods_file has been verified with the "if FileExists..." command . I installed version 5.3.7.2 (64-bit). OpenOffice is still installed.

edit retag flag offensive close merge delete

Comments

Cannot reproduce with 5.4.3.2, even when cd to the C:\Program Files\LibreOffice 5\program (but why would that be req'd? you can call "C:\Program Files\LibreOffice 5\program\soffice.exe" <switches> <paths> from any directory...)

Mike Kaganski gravatar imageMike Kaganski ( 2017-11-11 21:00:50 +0100 )edit

I decided to cd to the Libre Office 5\program directory because before I did that, I was getting an error message that said something to the effect that LO was unable to access its primary control information. After I added the cd, that problem disappeared.

Herb40 gravatar imageHerb40 ( 2017-11-12 04:08:50 +0100 )edit

I have since been able to get the following command to open the SS, but the macro is not executed: soffice.exe [switches] [path to .ods file] macro://[path to .ods file]/Standard.Starter.[macro name] which is similar to what I have been using successfully with OO. I'm going to revert back to my original approach (as Mike suggests) in which I cd to the directory containing all of my SSs and .cmd files and see how LO responds.

Herb40 gravatar imageHerb40 ( 2017-11-12 04:24:52 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2017-11-12 05:29:06 +0100

Herb40 gravatar image

I finally got everything right and am now able to open the SS and execute the desired macro. The final command in my .cmd script is:

"C:\Program Files\LibreOffice 5\program\soffice.exe" --nologo --norestore --nolockcheck %1.ods macro://%1/Standard.Starter.CmdA

where %1 is the file name of the SS (without the .ods) and CmdA is the name of the macro in the SS. The first reference to %1 requires the .ods to complete the path, but the second reference (in the full name of the macro) is a reference to the document object and must not include the .ods.

I was also able to replace the call to soffice.exe with a direct call to scalc.exe instead, assuming that this eliminates a small amount of overhead.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2017-11-11 20:54:10 +0100

Seen: 624 times

Last updated: Nov 12 '17