LibreOffice: Automatic export from PDF (Butt of robots with macros without knowledge of movie macros). Writing VBA macros in LibreOffice Excel macro converter in libreoffice calc

Golovna / Corisna information

I've been using Linux for almost 10 years now. About 5 years ago I started to vikorize the OpenOffice package, and 3 years ago - LibreOffice. As luck would have it, I don’t have a lot of macros written for Calc. And the axis for Excel has accumulated quite a lot over the past hour, starting with simple forms and formulas and ending with complex tasks for businesses that automate the preparation of information. Today, I made a vow to myself to slowly start wrapping the package in whatever way I can spend a good hour.


For most people, a macro is a completely unintelligible thing, and, perhaps, a blatant waste. For them, it not only does not optimize the work, but even more so. This thought is based on the unreasonable principles of vikoristan macros. Macros are modified only if it is necessary to modify them many times. Most often, it is the same type of document processing (folding formatting, selections), other forms for filling out, formulas, layout for graphs... Depending on the type of our progress, we choose a way to save our macros in:

  • global(or nadbudova) - always available when the program is opened;
  • formulaic- Available when you open a specific template;
  • local- Available only in a specific document.

The remaining content is reviewed more frequently, especially in complex interactive documents.
Today, only a few other companies that do not have IT specialists on staff use office packages (not important LibreOffice or MS Office) because they stink “out of the box”. In most cases, the office package is simply based on some kind of heated superstructure, and the company’s defense system often doesn’t suspect how many different, or even more powerful, things have been built up for the new one, until now Please refrain from transferring to another company.


For writing macros in Excel, we recommend starting with the “Record Macro” tool. Effectively, by writing down the details of the action, you just need to identify the surface level of the language and API that will need to be used. This is how you want to quickly create a clumsy macro, as if you were “writing it down”, and then polish it, finishing it in the code editor.

Connecting to the “Record Macro” tool in LibreOffice 4.1

In LibreOffice 4.1, the function " Record a macro» vimkneno. The first thing you need to do is turn on: ServiceParameters (ToolsOptions) open the LibreOffice group and at the very bottom in the item “ Expansion of possibilities» (« Advanced") put a check mark against " Enable macro recording (circumscribed)» (« Enable macro recording (limited)»).

What's in your menu: Service → Macros (Tools → Macros) menu item "appear" Record Macro» (« Record Macro»).

Useful version of the Record Macro tool in LibreOffice 4.1

To demonstrate the tool " Recording macros» pointable simple example:
1. Open a new Calc document and save it to disk under a manual name for you;
2. The middle is visible A1;
3. Enable macro recording Service → Macros → “Record Macro” (Tools → Macros → “Record Macro”). Open the panel with a single button " Complete Recording» (« Stop Recording»);
5. Apparently the middle B1 and pressed " Complete Recording» (« Stop Recording»);
6. The window will open now:

If you want a macro with access only in your document, then you can see the item with the name of the document (in case of article.ods, you will have the name under which you saved the document) and you can see the same library present Standard. It still doesn’t have any modules, so let’s do it.
7. Press the button " Create module» (« New Module") and in the window, enter the name of the module.

Once finished, the module is created with an empty macro under the name Main. Enter in the field " Imma macro» (« Macro name) bazhans ім'я ввів " Main") and pressed " Write down» (« Save") to save macro recordings. I have a problem with the idea that this is the name of the macro.

Recording macro, and if we now save a document, the macro will be saved along with it. So, once you open this document, we can use this macro.

Launching and editing the LibreOffice 4.1 macro

There are two ways to run a macro in LibreOffice 4.1.
First, open the window Viconati macro»: Service → Macros → “Viconati macro”(Tools → Macros → “Run Macro...”), see the required macro and press Launch».


Interface

However, it has completely matured in Microsoft Office Excel 2010.

In MS Excel 2010, this is the name of the “menu bar” - a revolutionary solution from the Microsoft company, introduced in MS Office 2007, as it was not enough to the soul and it was necessary to develop special utilities that would change the new look MS Office 2010 to MS Office 2003.

Let's take a closer look at the most important elements of the fortune-telling menu of electronic spreadsheet editors.

In spreadsheet editors (MS Excel, OOo Calc, LiO Calc, IBM Lotus Symphony Spreadsheets, etc.), the most important element is the “composition” and all operations that take place in spreadsheet editors are consolidated until the end or their group pi (rows , stovpts, etc.). So first of all, let’s take a look at the menu elements to format the middle ones.

In LiO Office, as in MS Office 2003, middle formatting is done through the menu item - “Format/Format” or the associated “Ctrl+1” key.

In MS Excel 2010, the middle formatting is available in the “Head” tab.

Other menu elements of MS Excel 2010 (Insert, Layout of pages, Formulas, Data, Review etc.) in LiO Calc are found in menu items similar to the name.

The next most important element of electronic tables is “Functions”, or “Formula”.

In MS Excel and LiO Calc, the names (abbreviations) of all formulas are similar, so the transition from MS Excel to LiO Calc for accountants who work in MS Excel will not be difficult. Get a detailed description of the functions and their similarities in MS Excel and OOo Calc (LiO Calc ) published on the website of the company "Infra-Resource", a wired solution integrator based on OpenOffice.org in the Russian Federation. But here there is a “underwater stone”... These are hot keys. For those who use the sound in MS Excel using additional hotkeys, there may be some inconveniences, both for ordinary users and for organizations, the fact that on one copy of MS Excel can be protected, as for me Minimum, $55, can serve Dosit a serious incentive to switch to LiO.


Crazyness

One of the biggest problems when switching from MS Excel to LiO Calc is the problem of insanity, and the biggest problem is working with macros. This problem was especially severe for versions of OpenOffice.org 1 and 2, but starting with version 3 of OpenOffice.org and LibreOffice it has practically been resolved. LibreOffice Calc 3.5 can accommodate most MS Excel macros. This function is enabled/disabled in the menu: Tools > Settings > Saving/Saving > VBA Power

The analogue of VBA in LiO Calc is Macro StarBasic (its version is LibreOffice Basic), which uses the same programming logic as Microsoft Visual Basic, so specialists who worked in MS Excel with macros will not need to get used to LiO Calc.

An analogue of VBA in LiO Calc is Macromov’s StarBasic.

Tim is no less, the problems are gone after all. On the right, the middle in which macros are written is the office package, not the macro package. Thus, our programming is not an independent core, but rather dependent on the internal object structure of the office package and the command call system implemented in the new system. The result is the technical impossibility of ensuring the full consistency of macros in various office packages. You will need to rewrite Microsoft Office macros before running them from OpenOffice.org or LibreOffice. Next, without going into all the technical details, I will say that there are converter programs that can help you work with VBA macros in LibreOffice. All possible work with VBA macros in the OpenOffice middleware are also examined in detail on the website of the company "Infra-Resource" (a marvelous thing) in the sections "Knowledge Base" and "Support for Backers of OpenOffice.org".

Well, to consolidate everything that has been said, let’s verify in practice the usefulness of MS Excel and LiO Calc documents. For this purpose, we have prepared templates for accounting documents from the website of the magazine “Chief Accountant”, which are prepared using MS Excel 97-2003 (XLS extension) and MS Excel 2010 (XLSX extension), and in which there is a large number of mathematical and economical Other functions. As a result of working with files (creating, editing, saving, converting to ODS), a regularity emerged: due to errors when macros are enabled, the versions of files saved in the MS Excel 98-2003 (.xls) format were affected. In versions created with MS Excel 2007-2010, errors occur much earlier.

Files created in MS Excel without using macros can be opened, read, edited, etc. we got going without any problems. Conversion from XLSX to ODS and back also converts without compromising on the saved text formatting parameters.

Files created in MS Excel without using macros can be opened, read, edited, etc. we got going without any problems.


Visnovki

With this rank, we can earn such crowns.

As for the LibreOffice Calc interface, those who previously worked in MS Excel 98-2003 will have no problems switching to Calc, but those who work with the “stripe” interface of MS Excel 2007 - 2010 , there will be noise until a little bit of a different type of work window.

LiO Calc data can be entered, edited, and sorted in the same way as in MS Excel. Frames are created in LiO Calc using the same functions as MS Excel.

As for working with macros, it should be noted that in versions of LiO Calc and OOo Calc 3.0 this problem is practically solved, and with any compromises it is possible to convert VBA macros into LibreOffice Basic.

Sergiy RIZHKOV

I publish any materials in two formats - odtі pdf. Remaining handy for all things to do. Export from pdf This can be done using standard LibreOffice tools through the dialog “ File → Export to PDF" In the process of reading and correcting documents, it is often necessary to save the document. And rather than manually export the document right away, I thought that it would be bad, but it would happen automatically when saving odf file. And knowledge of LibreOffice macros is absolutely not needed in this case.

The responsibility lies with the additional function of recording a macro. It is not available for cleaning. To extinguish it, go to “ Service → Settings"in separate" LibreOffice» select item « Expansion of possibilities" and check the box opposite " Enable macro recording».

After restarting LibreOffice in the " Service → Macros» appear item « Record a macro».

After the pressure " Tools → Macros → Record macro"On the screen there is a window with a button " End recording».

The point is simple:

  1. Turn off macro recording
  2. Click the necessary action while recording is in progress. For my option, I simply selected export from PDF via " File → Export to PDF»
  3. Press the button " End recording»
Everything, the macro for exporting to PDF is recorded, you can only save it.

For ease of reference, I created the module Export_to_PDF"at the librarian" Standard» Save your macro in this module.

Now there is no longer any need to remember to apply the macro to the song. Our partner has saved the document. Idemo in " Service → Customization" to the tab " Podii».

Invite denied. :)

Hello, Habrazhitels!
Today I want to tell you about the use of macros LibreOffice.

Peredmova
Every day, at home and at work, we use office programs for completing any tasks. It often happens that you specialize in one task and, as a result, end up doing the same tasks: inserting the same text, formatting it, using the same text, and using a large number of hotkeys. In all these situations, you can save your valuable working hours by automating your work.
Next, I will tell you about the use of macros LibreOffice.

What is this macro and all the stench?

Macro- This is the sequence of song actions that can be recorded using the secondary menu. When you select a macro entry, the actions you save are automatically saved in the script code view. And then your robot will finish on its own, exactly repeating your actions in the program. The macro can be either simple or even complex - everything depends on the result you need to achieve. The main criteria that are presented to macros are difficult and at the same time easy to understand in the vikoristan. LibreOffice macros provide such benefits. Let's try it practically.

For vikoristannya package LibreOffice You will need to have the Linux, Windows or MacOS operating system installed, as well as the LibreOffice package installed (you can install it, for example, from ppa repositories, as described in the topic)

Macro management

Before we can create our own macro, we need to become familiar with the macro management tool. Let's move along the road Tools - Macros - Organize Macros - LibreOffice Basic Macros(Service - Macros - Managing macros - LibreOffice Basic Macros):

In the left column of the window we can see a list of installed macros. Having pressed whatever it is, you can delete it or delete it.
Golovne zavdannya vikna- select the required macro, assign it to a button on the toolbar or associate it with any topic. Assigning a button to a macro allows you to quickly remove the most commonly used buttons from them.

I would like to point out that creating a macro in automatic mode (recording) requires little knowledge of how to write macros, so that we may need to edit it. To see what the macro looks like, select the macro we need and press Edit(Redaguvati). The butt is shown below, as the macro looks like in the output code:

Let's take a simple example. We have some text already inserted into the document and we need to create a title for it, because our text is vikoristic in the business listing.
Our upcoming macro may include:
- Place the text in the center of the page;
- enter the text that will be the title.
After creating a macro, it is important to use the button on the toolbar. After all, one click will be enough to insert a title into the document.
We determine the sequence of cuts.

Krok 1.
We open a text document. Let's move on Tools - Macros - Record Macro. A small window “Record macro” will appear with one button “End macro” ( Stop Recording):

Croc 2
Let's create a title for the text. Click the mouse on the button "Center alignment"(“In the center”), so that our current text is in the center of the document. Now we write the title text itself. It is not possible to specify different formats for a new one (font or bold/italics/emphasis), since the macro will not remember such actions.

Croc 3
After completing the creation of the header, click on the “Finish macro” button in the “Record macro” window. The Macro Organizer window will immediately appear. Enter a name for the new macro (for example, PostHead). Now you can save it in the place you wanted (for example, the folder " My Macro").

Krok 4
Now we are no longer able to add a button on the toolbar for macros PostHead. The process is not as simple as it would seem at first glance.
Vidkryvaemo LibreOffice Basic Macros, press the button " Assign"("Signify") It's time to show up Customize, in which slide go to the tab Toolbars And scroll down so that in the “Toolbar” field there is “Standard” ( Standard) .

Click on the “Add” button in this window ( Add). Another window will appear – “Add commands” ( Add commands).
There is a "Categories" window on the left side of the list ( Category) known " LibreOffice Macros Let's open it and get to our macro. As only those who knew, the remaining viconate and the simplest term were lost. Drag the Letterhead macro to the place in the toolbar where you want to display it.
That's all, they got out of the way.
Now all we need to do is press a button PostHead, Yaku we added to the panel. For example, we open a new document and press the button PostHead. Our macro creates a title, along with this text, that we “intended” for this document and places it exactly in the center of the document.
Really, really?

Pouch
Of course, in my application we created a very simple macro. In addition to the descriptions of other tools, you can create even more complex macros. And not only in Writer, and all other package add-ons LibreOffice(Spreadsheet, Presentations etc.). Now, if you know how to create macros, you can easily create vases in order to make your work easier.
The purpose of this article is to learn the basics of working with an additional tool for recording macros.

Sometimes it is necessary to work with the text or process the text in any complex way and in some basic ways that are provided by the interface for which it does not work. In addition, it may be necessary to carry out the same sequence of routine actions, which takes many hours, but I would like to know the sequence of these actions until one press of a button. Writer allows you to create special macros, which are essentially text processing procedures for writing your program; in our case, the language program is BASIC. In this case, without any standard operators of high-level government programs, you can deny access to objects of the Writer text editor, open documents, document opening functions, all objects of this document, including chi little ones, paragraphs, footers, vision text, lists , words, letters, fonts, etc.

2.1. Objects and class.

What is the Object? From the point of view of the real world, the object is more material, obviously, and driven by the authorities and behavior in the real world, often the objects appear to be similar to the powerful authorities, whichever way we bring the object to the surface. which class of objects. For example, a car, which has different specific implementations and objects, is a car, and in the final class is a car that has wheels that are driven and covered with water. The same can be said about the text or the document, the document itself, which contains the text object, and the text object contains the objects words, paragraphs, letters, the text is edited, changed, displayed, the document is created and saved. All our actions are linked to these objects, vikorist functions of the editor, and we can also click on these functions for additional algorithmic language.

If you have already worked with languages ​​and written programs, then you know that in any language program there is a set of operators or instructions, with the help of which you can write instructions or programs, as you can understand. ti ta viconati processor. There is a set of standard operators in addition to which you can write practically any algorithm, no matter how complicated - a sequence, a cycle, a linear sequence of operators, arithmetic operations and the ability to scale up to changeable and record in them there is a significance of both the results of logical and arithmetic expressions. In order for high-ranking languages ​​to be used to remove folding robots from the memory of powerful machine languages, a standard operation is introduced that allows the song - change - symbolic sequence to be given as a value. Roughly seeming, vikoryst this symbolic sequence in the images you work with to fit into this change as in the screenshot. The assigned operation can be described as follows: In a bottle with the name St1, we pour milk from the mug Cr1 and we say, pour milk St1 from Cr1. In this manner, you will find those who are located at Cr1. The same and the same. Valid, Val1 = 20; Val2 = 30; Val3 = Val1 + Val2; Then Val3 can accommodate a value of 50. You know that the change can only accommodate only the data of the current type, and not all of it (you want to create a special variant data type, if the type of change can be determined in the process and wiki programs). We can also save names (rows), numbers, and objects. Therefore, each type of data is assigned to each type of data, either the domain or the area of ​​​​the value that can be acquired. Define language programming - whole types, speech, rows, symbols, logical, overhauls, multiplicities, complex numbers, record types or structures. So, such a changeable object, which is sent to an object that has a foldable structure of data, allows you to combine methods of working with this data and object, as well as protect the data, separate it, or allow access to it.

A changeable object, which is changeable to accommodate other objects, powers and affairs that hover over an object, an object with a specific implementation of a certain class (a class is a description of a particular class) What are the same objects? by the authorities themselves). Define access to authorities and functions of complex data types (such as classes) by writing the name of the variable object, and then through the name dot of the function or authority of this object.

2.2. Changeable objects in Basic

To delete a change, specify the keyword dim and then a list of changes through whom, the word as and the type of change.

Dim a, b as integer – confusion of a whole type. Dim s as string – stunned ordinary type.

Dim mass() as integer – detonation of a dynamic single-dimensional array of a whole type. Redim mass(100) – change the maximum mass and set it to equal 100.

Dim desk as com.sun.star.frame.Desktop – is an exchange for the desktop type of the unified UNO grid model, which can be used for objects of the Desktop type.

In Movi Basic, you can navigate to make changes to objects, such as text, paragraphs, tables, that are displayed on the window screen, and you can control a set of controls and methods for working with these objects. The object model can be of any kind, as is its implementation, for example, the Microsoft Office package has its own object model, the LibreOffice or OpenOffice package has its own, so the objects have a way of interacting with these objects in these various packages are damaged.

2.3. Basic Operators

For loop operator.

For index=n1 to n2 Rem cycle body

The Index variable runs through the values ​​from n1 to n2 with increment s (increase by s), in this case s can be variable or a constant of the integer type, square arms indicate that the design is not binding oh, if you don’t say so, it’s very old 1.

For example, val =0

For xyz = 4 to 50 step 4 val=val+xyz

The algorithm calculates the sum value from 4 to 50 with the symbol 4, then the sum is 4, 8, 12, 16.

up to 48 minutes val. val1 =0

For aval = 1 to 50 val1=val1+aval next aval

Once the sum of whole numbers from 1 to 50 is insured.

Operator for the While loop, work until the end of the mind. The statements in the middle of the cycle are repeated until the end of the cycle.

While<условие>operator Wend

Butt: While i

The loop continues until the change is less than N. Mental operator If,

if<условие>then

<последовательность операторов если условие выполняется>end if

Butt: if I is less than 100 (if you are a viconan), then increase I by 1, otherwise change it by 1.

If i<100 then i=i+1

else i=i-1 end if

2.4. Procedures and functions.

Functions and procedures are outside blocks of statements that can be called in the main program or subprogram, causing the function or procedure to be called in the program by inserting their names and the parameters that are transferred to it, after selecting the control function operators, the program or subprogram is clicked This begins the identification of operators responsible for the function and procedure. Obviously, the importance of procedures and functions is to ensure that you do not immediately write the same code for operations that are often repeated, concluding with a logically completed action. In this case, in the middle of functions and procedures, you can change your local changes, which can be the same names that are changed in other procedures, functions and in the main program. In whose name the procedures can be changed by local change functions. A typical selection of procedures and functions lies in the fact that we pass certain values ​​to the function, based on which function selects a series of actions and calculates the result. The main versatility of procedures in functions is that called the association function, which type of data is rotated, roughly speaking, the function can be used in expressions, for example, arithmetic or logical, in mental operators and cycles. The procedure follows every step of the way.

The function rotates the sum of two numbers, which are passed as actual parameters to the function from external programs

Function sum(a,b as integer) as integer Sum=a+b

Use the sum function in the program. Dim x as integer

x = 2 x = x + sum (x, 4) * 2

An example of a procedure that allows you to combine two numbers, the value is rotated in the formal parameter 3, when the procedure is called, it does not have to be a constant, but can be a changeable type integer

Sub sum(a,b,c as integer)

Dim c as integer Call sum(2,2,c)

2.5. Creating a macro in LibreOffice

To create a macro in LibreOffice, select service+macros+manage macros+LibreOffice Basic (Tools+Macros+Organize Macros). When the window appears, it is shown a little lower (Figure 19). To create a saving macro for the document itself, you must select your document, select the “standard” set of standard modules and then click “create”, then you must enter the name of the module. After creating the module, you can select it, in the right-hand window, select the Main macro and click Edit. Otherwise, after creating the module (Module1), write a new name for the macro in the Macro Name field and click create (Figure 20).

Malyunok 19 - Easy creation and editing of macros

Figure 20 – Butt of the new MyMainMacros macro

As a result of creating and editing the macro, the BASIC editor window appears, an example of two macros is pointed at the little one, of course there may be more of them and they may include input parameters.

Figure 21 - Basic editor and two macros

LibreOffice, as already mentioned, has a much different object model than Microsoft Office; LibreOffice Basic has a similar unified UNO object model. The butt of the OpenOffice macro is set lower to a larger size for the font of the skin paragraph.

Dim Doc As Object

Dim Enum As Object

Dim TextElement As Object

" StarDesktop - the main object available from the macro

" creation object enumeration

Enum = Doc.Text.createEnumeration

" loop through all text elements While Enum.hasMoreElements TextElement = Enum.nextElement

" Verification of a flow block with a table

If TextElement.supportsService("com.sun.star.text.TextTable") Then

MsgBox "Flow block place table"

© 2022 androidas.ru - All about Android