How to run python macros in LibreOffice?

北城以北 提交于 2020-06-24 07:14:10

问题


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


回答1:


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.




回答2:


I also struggled to get a clear start, so I documented my setup and the things I learned here. If you work through that, you will see that you can place your python script in any folder as long as you link to it correctly.

EDIT: The old URL-only answer now points to a dead link. That page can still be found on the Internet Archive Wayback Machine or this GitHub Gist.




回答3:


Python scripts are located on /usr/lib/libreoffice/share/scripts/python

Maybe this tutorial will help, as it did for me.




回答4:


Follow these instructions:

  1. Install the new APSO extension
  2. then go to Tools -> Macros -> Organize python scripts.
  3. Now, select "My Macros" and choose Menu -> Create Module.

This documentation helped me the most.



来源:https://stackoverflow.com/questions/21413664/how-to-run-python-macros-in-libreoffice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!