Programming LibreOffice Base. Part 1

  • Tutorial
OpenOffice and LibreOffice open source office suites have a rarely used and very poorly documented feature - programming, which allows you to quickly develop applications similar to, for example, Microsoft Access applications. Today I will give a short overview of the programming capabilities of OpenOffice, LibreOffice.

Question: why?

I will not interfere in historical reasons now, because for employees involved in automation - these are company managers, and distributors of ERP systems, and IT services within the enterprise, and consulting - all have their own reasons (often supported by monetary gain) to defend precisely their point of view. But I think everyone will agree that Excel and its free analogue Calc (from the OpenOffice, LibreOffice package) are used very widely in the daily work of enterprise divisions. And even if such a phenomenon exists, then it can be argued that this is no longer an accident, but a production necessity, so to speak, and certainly not the fault of the workers - but rather a shortcoming of automation.

In OpenOffice, LibreOffice packages there is a component for working with databases - Base. I tried to master working with it even before OpenOffice, LibreOffice - in the days of StarBase. But all my attempts rested in the complete absence of documentation on development (programming). Today, documentation is still scarce, and probably the most useful resource is the book of the great programming enthusiast OpenOffice, LibreOffice - Andrew Pitonyak . A book was also published in Russian, including Chapter 7. OOo Basic Language - UDC 681.3.06 BBK 32.973.26-018.2 K59 Kozodaev, R. Yu. K59 OpenOffice.org 3. Complete User Guide / R. Yu. Kozodaev, A V. Majugin / Ed. E.V. Ushakova. - SPb .: BHV-Petersburg, 2010 .-- 704 p.: Ill. + Distribution (on CD-ROM) - (GNU / Linux Center Library) ISBN 978-5-9775-0385-3

Therefore, as a distribution of information about the programming capabilities of OpenOffice, LibreOffice with an emphasis on the Base component, this message was created.

The LibreOffice package is now relevant in version 6.2, which can be obtained on the developer's website .

Also, the package is preinstalled on many Linux distributions (sometimes the Base package is not preinstalled, since it is relatively rarely used).

At the stage of creating a new Base database, you can choose the option of working with the built-in database or join the database server. That is, multi-user work is supported. For experiments, you can choose any of the options.

The macro editor is opened by a sequential selection of menu items Tools-> Macros-> Organize Macros-> LibreOffice Basic.

You will see a choice of location for storing macros. It will be most logical to store macros in a database file, because they can then be distributed in one file.

Create the simplest macro:

Sub Hello
  MsgBox "Hello"
End Sub

Next, create the form Forms-> Create Form In Design View . And add a button element in the form constructor. After creating the button, open the button properties palette by clicking the right mouse button and then sequentially choosing Control-> Execute Action-> Macro-> Library Name-> Hello .

Having saved the form, we call it to execute and observe the work of the macro. Or do not observe. It's all about protection, which, due to the increasing number of malicious macros, disables their work by default.

If that will cause at least some interest, I’m ready to continue with more specific topics.

Also popular now: