Bug 104441 - There is no documentation in the help on how to open a file and automatically run a macro
Summary: There is no documentation in the help on how to open a file and automatically...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: tagezi
URL:
Whiteboard: target:5.4.0
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-06 16:18 UTC by Alan
Modified: 2022-03-04 14:50 UTC (History)
1 user (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan 2016-12-06 16:18:03 UTC
Description:
The format to automatically run a macro when opening a document via the command line is missing from the LibreOffice help. This is needed to automate workflows using scripts.

Steps to Reproduce:
1.Look in the help
2.Not present
3.

Actual Results:  
<no results>

Expected Results:
Suggested text: To run a macro on startup from the command line or a script the format is soffice FileName macro:///Path.To.Macro

FileName is the full file name of the document/spreadsheet
Path.To.Macro is the full path to the macro as seen in the LireOffice Basic Macros dialog window.
So an example to open a spreadsheet and execute a macro named Startup in Module1 would be:
soffice MyFile.ods macro:///Standard.Module1.Startup


Reproducible: Always

User Profile Reset: No

Additional Info:


User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:48.0) Gecko/20100101 Firefox/48.0
Comment 1 tagezi 2016-12-06 16:37:08 UTC
I confirm it.
Comment 2 Commit Notification 2016-12-17 19:19:13 UTC
tagezi committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/core/commit/?id=2c9972b8d40dce72cc6f56f1d44db838bd0ece10

tdf#104441 Addition to output to the console help

It will be available in 5.4.0.

The patch should be included in the daily builds available at
http://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
http://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 3 tagezi 2016-12-17 19:29:26 UTC
This patch was for output to the console.
For online and build-in Help it was added in https://gerrit.libreoffice.org/gitweb?p=help.git;a=commitdiff;h=47ad5a2f2102740bda4cf02dcd73562da79f67a9

So, I think that it is fixed.
If you have any comments, I am ready to listen.
Comment 4 Mike Kaganski 2017-01-27 07:36:18 UTC
I wanted to amend the information as available on http://www.script-coding.com/OOo/OOo_HelloWorld.html:

You can execute a macro from a command line, like this:
> soffice -invisible macro:///standard.module1.mymacro
Here "standard" is a name of a library from "My macros" container, "module1" - module name, "mymacro" - name of function (sub) of macro itself. This will start a LibreOffice process, which will execute the macro and exit.

You can start a macro of a specific document at its opening from a command line:
> soffice path/to/test.odt macro://./standard.module1.mymacro

If e.g. test1.odt document is already opened, this command line will also work:
> soffice macro://test1/standard.module1.mymacro

A macro may be executed from another macro code (using similar URLs), like this:
 oDisp = createUnoService("com.sun.star.frame.DispatchHelper")
sMacroURL = "macro:///standard.module1.mymacro"
oDisp.executeDispatch(StarDesktop, sMacroURL, "", 0, Array())