Ask Your Question

CLI for Basic Editor?

asked 2017-06-11 23:18:45 +0100

lif3l3ss gravatar image

Hi all, is there a command line interface for the Basic Editor? I would like to edit and save macros for a doc file using the command line, if possible.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2017-11-04 16:33:04 +0100

Jim K gravatar image

updated 2017-11-04 16:36:08 +0100

@techsquirrel's answer interprets the question as asking about system-wide macros. However if "for a doc file" means macros that are embedded in the file itself, then that will not work.

To modify macros built into an ODT file, unzip the ODT file and then find the macros inside XML files. This may also be possible with DOCX, although I have not tried it.

It is not possible to unzip the DOC format. I do not think there is any good way to modify macros embedded in DOC files from the command line. Even Apache POI does not support macros.

One final possibility: Create a macro that works with, the Basic Editor component. See for example This looks like it could work if the editor is already open, although I do not see an example of how to automate opening it.

edit flag offensive delete link more

answered 2017-11-03 23:38:40 +0100

Not really, as far as I've been able to determine. However...

You can edit a macro in a text editor outside of the Basic Editor, and you can run a macro from the command line.

For example, say you create a (really) simple macro in the Basic Editor within Standard.Module1...

Sub Main
print "This is a macro!"
End Sub

...and then close LO.

Then, as presented on page 135 of Andrew Pitonyak's "Useful Macro Information For" (, you can run the macro from the command line like this...

soffice macro:///standard.module1.main

The result is a dialog box with the message "This is a macro!"

Then, if you go to the directory containing the macro in your LO profile (your directory location may differ)...

cd ~/.config/libreoffice/4/user/basic/Standard can edit the file corresponding to the module (in this case Module1.xba) in any text editor (vi, for example). So, say you edit the file, add the word "DEFINITELY" to the print statement, save the file, and run again as above. Then you'll get a dialog box with the message "This is DEFINITELY a macro!"

Whatever changes you make to macros outside of LO will show up in those macros within LO when it's next opened. But if you edit macros while leaving LO open, changes to those macros won't show up in LO until it's closed and then opened again. And I don't know what'll happen if you edit a macro outside of LO with LO open and edit the same macro within LO before closing and then opening LO to pick up the changes from outside, so I'd be careful doing that.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2017-06-11 23:18:45 +0100

Seen: 90 times

Last updated: Nov 04 '17