Use Visual Studio Code to edit LibreOffice Macros
During the development of macros in LibreOffice it is very useful to use an IDE like Microsoft Visual Studio Code to be able to use all the features of the environment.But unfortunately the use of external editors in LibreOffice needs some additional help
The first step to reach this target is to install the APSO-Extension. This Extension gives you the ability to configure an external editor for your python macros and a shell to the python installed with LO.
Just download the extension from the website (apso.oxt) to your pc or mac. Then open LibreOffice and install the extension (screenshot is MacOs):
Use the «Add» button and choose the extsion from the destination folder of your download.
Now click on «Open» and install the apso-extension. After that a restart of LibereOffice is useful. When LO is available again return to your extensions and you will recognize that the APSO Extension is installed.
Now choose the extension with your mouse and click on the «Options» button to configure apso.
In the dialog box choose the entry «APSO - Editor Kicker». If you use either Windows or Linux OS then type the path of you VSCode installation to the field called «Editor».
If you work on a Mac(something) you need to use the terminal program called «open» in the «Editor»-field. To be able to edit a macro you need to add some more options.
In this example we start the «open» application with the parameter «-a Visual\ Studio\ Code {FILENAME}» which opens Visual Studio Code and opens up exactly the macro-file you want to edit.
If you want to add a macro using Python in VSCode you need to open a file in LibreOffice. Then go to the menu
Extras - Manage Python-Scripts. The next screen offers the oportunity to choose the place where you want to store your script.
You can choose different places to store your macro. If yout want to store it in the current document or spreadsheet then choose the spreadsheet and use the menu to create a new module (if you want to create a module). This enables you to name the module.
After assigning a name to the module you will be able to choose the new Module in your spreasheet (or writer-document, or presentation or....). Click on your newly generated module and choose the entry «edit» to open the file in VSCode.
After that your module will be opened in VSCode. Now you can type your code, debug and test it. Save the file and your macro will be available in your document (or spreadsheet, presentation, draw.......).
Now choose your newly created module from the menu: Now you are able by using the right click context menu to choose what to do with your code:
We will choose to debug the code.
This decision opens the apso-degugger.
In the next step we will open up an addtional plugin to ease up python development in LiberOffice. Stay tuned and have fun!