Page 1 of 1

[Solved] Can't find place to create a python macro

Posted: Tue Dec 11, 2018 5:33 pm
by jason1984
Hello, I did lots of search but couldn't find steps to create a python macro for a linux system.

Under the Libreoffice-Tools-macro menu I find :
1. run macro
I can run "Hello world" python macro just fine but can't create one.
2. edit macro
I can only find many macros written only in Basic language. If I try to write my python macro start with "import uno" in it I get syntax error.
3. manage macro
All the 'create', 'edit" buttons are grayed out.

So, where do I create my own python macro? Thanks.

Re: Can't find place to create a python macro

Posted: Tue Dec 11, 2018 6:05 pm
by FJCC
You can write Python macros with your favorite text editor and save them in the folder
/home/username/.openoffice/4/user/Scripts/python
using the .py file name extension. They will then appear in the MyMacros section of the OpenOffice macro organizer.

Re: Can't find place to create a python macro

Posted: Tue Dec 11, 2018 7:44 pm
by Villeroy
With LibreOffice the script path might be ~/.config/libreoffice/4/user/Scripts/python/

Have a look at Tools>Options>Paths
The default paths for templates, galery etc. indicates the profile folder.

See also: https://extensions.libreoffice.org/exte ... thon/1-0.0

Re: Can't find place to create a python macro

Posted: Wed Dec 12, 2018 4:19 am
by jason1984
Thank you for helping.

Under my user folder it is:

Code: Select all

~/.config/libreoffice/4/user> ls
autocorr  autotext  backup  basic  config  database  extensions  gallery  pack  psprint  registrymodifications.xcu  store  uno_packages  wordbook
There's no ./Scripts/Python there. Manually creating one won't make it appear in Macros.

On the other hand, I notice that in Libreoffice-Tools-Options-Path, I have
Classification pointing to /usr/lib64/libreoffice/program/../share/classification/example.xml,
which led me to find /usr/lib64/libreoffice/share/Scripts/Python.

It seems I somehow need to let Libreoffice be aware of python scripts under my home folder so I don't always need root privilege to create a python script in /usr/....Python?

Re: Can't find place to create a python macro

Posted: Wed Dec 12, 2018 2:08 pm
by John_Ha
See Spell checker "red wriggly lines" - beta test fix for AOO for detailed instructions on how to install a python macro.

Showing that a problem has been solved helps others searching so, if your problem is now solved, please view your first post in this thread and click the Edit button (top right in the post) and add [Solved] in front of the subject.

Re: Can't find place to create a python macro

Posted: Wed Dec 12, 2018 4:58 pm
by Villeroy
download/file.php?id=36285 is an example macro distributed as a Writer document with an installer written in Basic. The path and file name is stored in a user field.
The attached template lets you create such an installer. Open the template, double-click the user field, modify the field value, replace the place holder with your source code and save the document in a trusted directory where document macros are allowed to be run (Tools>Options>Security>MacroSecurity>Trusted Sources).
The macro appends the user field value to the profile path, creates the directory if needed and saves the document as plain text which saves the plain text body without the frame and button.

Re: [Solved]Can't find place to create a python macro

Posted: Wed Dec 12, 2018 6:35 pm
by jason1984
The problem seems to be needing ..../Scripts/python instead of "Python".