📜 ⬆️ ⬇️

Programming LibreOffice Base. Part 1

In the open source office suites OpenOffice, LibreOffice is a rarely used and very sparingly documented feature - programming, which allows you to quickly develop applications similar to, for example, Microsoft Access applications. Today I will do a small overview of the programming capabilities of OpenOffice, LibreOffice.

Question: why?

I will not now intermeddle in historical reasons, because for employees involved in automation, they include business leaders, distributors of ERP systems, IT services within the enterprise, and consulting — all have their own reasons (often supported by monetary gain) to defend their point of view. But I think everyone will agree that Excel and its free analogue Calc (from the OpenOffice package, LibreOffice) are used very widely in the daily work of the enterprise divisions. And 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 shortage of automation tools.

In the OpenOffice, LibreOffice packages there is a component for working with databases - Base. I tried to learn how to work with it even before OpenOffice, LibreOffice - in the days of StarBase. But all my attempts rested against the complete absence of documentation on development (programming). As of today, there is still little documentation, and probably the most useful resource is the book of the great programming enthusiast OpenOffice, LibreOffice - Andrew Pitonyak . A book in Russian was also published, including Chapter 7. OOo Basic Language - UDC 681.3.06 BBK 32.973.26-018.2 59 Kozodayev, R. Yu. K59 OpenOffice.org 3. Complete User Guide / R. Yu. Kozodayev, A . V. Majugin, Ed. E. V. Ushakova. - SPb .: BHV-Petersburg, 2010. - 704 pp., Ill. + Distribution (on CD-ROM) - (GNU / Linux Center Library) ISBN 978-5-9775-0385-3
')
Therefore, as a dissemination of information about the programming possibilities of OpenOffice, LibreOffice with the emphasis on the Base component this message was created.

The LibreOffice package is now relevant in version 6.2 which can be obtained from the developer’s website .

The package is also 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 database, Base, you can choose the option of working with the embedded 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 can be opened by sequentially selecting the menu item Tools-> Macros-> Organize Macros-> LibreOffice Basic .

You will be presented with a choice of location for storing macros. The most logical would be to store macros in a database file, since in this case they can be distributed in one file.

Create the simplest macro:

Sub Hello MsgBox "Hello" End Sub 

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

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

If the topics cause at least some interest is ready to continue with more specific topics.

Source: https://habr.com/ru/post/445074/


All Articles