Wednesday, June 20, 2018

LibreOffice Basic well hidden secrets

Last week I wrote a quite long help page on a poorly known feature of LibreOffice aimed to Basic macro programmers.

LibreOffice - since it was named OpenOffice.org long time ago - carried a set of Basic libraries with no documentation (that I was able to find). The libraries were created to support some important features such as Euro conversion or WikiEditor, but also had a set of modules and macro very handy for the ad-hoc or professional Basic programmer of LibreOffice.

The library is distributed in the LibreOffice installers and can be opened in the LibreOffice Macros container, accessible when opening the Basic IDE.





I got fond of the TOOLS library because it has many handy macros that otherwise requires quite a lot of hard code writing and LibreOffice API knowledge even for simple operations.

Things like getting the last used row in a spreadsheet, get the value of a cell, get the filename out of a long URI are the kind of Function's and Sub's we don't want to write again but use GetLastUsedRow, GetValueofCellbyName or FileNameoutofPath for the task.

To use the LibreOffice Tools library , add the statement

GlobalScope.BasicLibraries.LoadLibrary("Tools")

before the first macro of your module. The help page is already online in 

https://help.libreoffice.org/6.1/en-US/text/sbasic/shared/03/lib_tools.html

Note that not every library is described in details in the set of Help pages but if you feel motivated to peek in the code and write a simple description of the remaining modules and macros, join our documentation team!

Happy macro programming!