Search code examples
pythonlinuxlibreofficelibreoffice-writer

Can't run Python macro in LibreOffice


I'm trying to learn to write macros for LibreOffice in Python. I made simple macro, put in into ~/.config/libreoffice/4/user/Scripts/python/ and found it in Tools/Macros/Organize Macros/Python.../My Macros. So far all works as expected, macro is visible.

But when I click on it, the Run button stays grayed out. I cannot run it. Does anyone know what might be the cause?

Thanks

EDIT: File is executable, I set the rights to 777 just to be sure. Python code is valid.

EDIT2: I reinstalled LibreOffice and it works now. Probably was something wrong with my installation. Script file in ~/.config/libreoffice/4/user/Scripts/python/ set as executable works. And @ngulam examples worked even before reinstall.

Thanks for all the advice you've given me and have a good day.


Solution

  • Macros for OpenOffice/LibreOffice in Python don't have to be executable.

    The location is right, though you might want to create a sub-directory (e.g. for CALC or WRITER), and put it in there - since otherwise it will be visible in all other components (where it might not work).

    Did you restart LibreOffice after copying?