How do I run a LibreOffice macro from the command line without the GUI?

dimpol

I want to run a LibreOffice macro on .odt file(s) from the command line. Because I want to scale this up to applying the macro to multiple files, I don't want the GUI to pop-up in each execution of the macro.

I currently have a working macro (that also closes the file at the end) and as far as I can find, I should be able to call it as followed:

soffice --invisible --nofirststartwizard --headless --norestore "D:\myFolder\my file.odt" "macro:///Standard.Module1.myMacro"

or

swriter --invisible --nofirststartwizard --headless --norestore "D:\myFolder\my file.odt" "macro:///Standard.Module1.myMacro"

Both commands execute the macro correctly, however the GUI opens and closes during execution. How do I prevent this?

I am working on a Windows 10 Computer and Help>About LibreOffice gave the following info:

Version: 5.2.1.2
Build ID: 31dd62db80d4e60af04904455ec9c9219178d620
CPU Threads: 4; OS Version: Windows 6.2; UI Render: default;
Locale: en-US (en_US); Calc: CL

Jim K

The problem is that even though LibreOffice is invisible when started, it becomes visible after opening a document. There is a solution at https://forum.openoffice.org/en/forum/viewtopic.php?f=5&t=22548:

  1. Run LibreOffice headless to call a macro. The command line call should not specify the document to open, just a macro. For example (using the newer macro syntax):

    soffice -headless -invisible "vnd.sun.star.script:Standard.Module1.MySubroutine?language=Basic&location=application"

  2. The macro calls loadComponentFromUrl with the Hidden property set to true. This will cause the document to not become visible.

  3. Now the macro performs whatever it was going to do with the document.

EDIT:

To make it work for different files, pass the filename as a parameter using the older macro syntax. An example from https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=8232:

soffice "macro:///Library3.Module1.test_Args(arg1,123,4.567,2000-12-31)"

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

How do I evaluate form inside lambda that is within a macro?

How do I enable line numbers in Kakoune?

Windows: How can I use the command line to set registry permissions

Windows: How can I use the command line to set registry permissions

How to run Maven from another directory (without cd to project dir)?

LibreOffice Macro无法识别JRE

how do i use arrays in this code to make it run faster?

How do I concatenate two vectors with one line of code

LibreOffice Macro-访问脚注文本

How do I do the command Alt+M T D in LyX?

没有gui更改的libreoffice 4.4

How to start remote command line session?

How to install/run autohotkey without admin privileges?

How do I run a global npm program when an ubuntu program has the same name?

How do I avoid an 'unbound variable' error when the query is unknown at compile but known when the function would be run?

How do I sleep my computer from within python?

How do I UPDATE from a SELECT in SQL Server?

How do I UPDATE from a SELECT in SQL Server?

How do I get data in subcollection from filtered document in Firestore

How do i change from mouse to touch instead?

How do I access random elements from a vector in R studio?

How do I access a thread from another scope?

How do I get property value without knowing it's specific key in javascript using JSON

When i try to run makemigrations command in django it gave me an error

LibreOffice Macro始终显示#NULL!重新打开文件后

I want to extract strings from a line

How does Mac's command line compare to Linux?

How can I repair the disk by command?

How to read complete line without any mapper with spring batch