Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run python macros in LibreOffice?

When I go to Tools -> Macros -> Organize Macros -> Python I get this dialog:

enter image description here

It is not possible to create new Python macros.

Apparently LibreOffice has no Python editor so I have to write the macros elsewhere and then just execute them.

But I do not know where to put the Python scripts.

I tried a system-wide search for files with "HeloWorld" in their name and I got no results.

I tried to put a test.py file into:

/home/martin/.config/libreoffice/4/user/Scripts 

and reload the application, but the test macro is not shown.

I tried to find the appropriate setting in Tools -> Options -> Path but there is no "path to macros":

enter image description here

How can I run Python macros from LibreOffice?

This question is a part of my quest to learn Python and to learn LibreOffice macros, so any link to a general tutorial is welcomed. The tutorials on LibreOffice Python macros seem to be especially hard to find.

I am using LibreOffice Version: 4.1.3.2

like image 417
Martin Drozdik Avatar asked Jan 28 '14 18:01

Martin Drozdik


People also ask

Is LibreOffice compatible with Python?

Working with Python Scripts in LibreOfficeYou can execute Python scripts choosing Tools - Macros - Run Macro. Editing scripts can be done with your preferred text editor.

Can I use Python for macros?

You can write an Excel macro in python to do whatever you would previously have used VBA for. Macros work in a very similar way to worksheet functions. To register a function as a macro you use the xl_macro decorator. Macros are useful as they can be called when GUI elements (buttons, checkboxes etc.)


1 Answers

Try to manually make a subdirectory python (all lowercase) inside /home/martin/.config/libreoffice/4/user/Scripts and put your script there.

This is based on this wiki.openoffice.org documentations.

like image 139
halex Avatar answered Sep 25 '22 06:09

halex