Ask Your Question

How to apply the same macro code to different ODT files

asked 2015-09-08 16:08:50 +0100

xn2015 gravatar image

updated 2015-09-14 20:51:33 +0100

I have a lot of ODT files and would like to apply the same macro code to them. I don't want to open the ODT files and paste the macro code manually.

Given the basic macro code is in myBasicMacroCode.txt, what is the command line to tell libreoffice writer to run myBasicMacroCode.txt in ODT file?

I'm running LibreOffice 430m0(Build:2).

Edit 1:

I want a command line or some kind of automate process that I can call because I have thousands of new odt files to process every other weeks.

What I found is you can execute the macro code as follows

libreoffice --headless "macro://./Standard.Module1.YOUR_MACRO" yourfile.odt

But there is catch, YOUR_MACRO needs to exist in yourfile.odt. If you someone can tell me how to inject automatically the macro code in the odt file, then it will solve my problem.

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2015-09-11 16:01:00 +0100

g2gsoon gravatar image

Create a macro inside My Macros & Dialogs Module1 and paste your code into there. This macro can then be called from any libre office file you own and has a button pointing to it.

edit flag offensive delete link more

answered 2015-09-12 22:20:05 +0100

LKeithJordan gravatar image

In MS-Word, you would create a template that includes the macro code and attach the document to the template. As a LO newbie, I suspected the same would be true for Writer, but I wanted to check first.

It seems my suspicions were correct. Here are a few links that appear to be on point:

Hope these help.

edit flag offensive delete link more


Thx for your effort in answering but these links are not helpful.

Maybe I wasn't clear. I know how to do it manually by hand(i.e. by clicking) but I have thousands of new odt files every other weeks. I don't want to do this by hand. I want to a command line instead of clickings so that I can include in a process.

I will update my question.

xn2015 gravatar imagexn2015 ( 2015-09-14 20:40:53 +0100 )edit
Login/Signup to Answer

Question Tools



Asked: 2015-09-08 16:08:50 +0100

Seen: 219 times

Last updated: Sep 14 '15