Jul 14, · Type a descriptive name and click OK to create the module. The datingescortusa.com Basic Macros dialog is displayed again, showing the new module. Highlight the newly created module. In the upper left corner, type the macro name to use, such as “EnterMyname", and then click Save to . Jul 15, · Using a macro as a function. Use Tools > Macros > Organize Macros > datingescortusa.com Basic to open the datingescortusa.com Basic Macros dialog. Select the NumberFive macro and click Edit Change the name of NumberFive to NumberFive_Implementation (see Listing 3). In the Basic IDE, hover the mouse cursor.
Contributors are listed below. Note: Everything you send to a mailing list, including your email address and any other personal information that is written in the message, is publicly archived and cannot be deleted. The contributors to that chapter are:. Some keystrokes and menu items are different on a Mac from those used in Windows and Linux. The table below gives some common substitutions for the instructions in this chapter.
For a more detailed list, see the application Help. Access setup options. How the macro recorder aa the dispatch framework. Toolbars, menu items, and keyboard shortcuts.
A macro is a saved sequence of commands or keystrokes that are stored for later use. The LibreOffice macro language is very flexible, allowing automation of both simple and complex tasks.
Macros are very useful when you have to repeat the same task in the same way over and over again. LibreOffice macros are usually written in a language called LibreOffice Basic, sometimes abbreviated to Basic. Although you can learn Basic and write macros, there is a steep learning curve to writing macros from scratch.
The usual methods for a beginner are to use macros that someone else has written or use the built-in macro recorder, which records keystrokes and saves them for use. Now first step in learning macro programming is to find and use existing macros. This section assumes that you have a macro that you want to use, which may be in an email, on a web page, or even in a book.
For this example, the macro in Listing 1 is used. Sub HelloMacro. Print "Hello". End S ub. A module named Module1 already exists and can contain your macro. If you wish, you can how to create a macro in openoffice calc New to create another module in the library.
Listing 2 shows the new macro has been added before Sub Main. End Sub. If you have to repeatedly enter the same information, you can copy this information after it has been entered into your document for the first time, then paste the information into your document each time you want to use it.
However, if something else is copied to the clipboard, the contents caoc the clipboard are changed. This what is the definition of marquee that you have to re-copy your repeated information.
To overcome this problem, you can create a macro that enters your repeated information. For some types of information that you want to repeatedly enter into a document, it may be more convenient to create an AutoText file.
By default, this feature is turned off when LibreOffice was installed on your computer. A small dialog is displayed indicating that LibreOffice is recording a macro. As an example, type your name. Note that every library container has a library named Standard. This opens the Mafro Module dialog. If you followed all of the above steps, the Standard library now contains a module named Recorded and this module contains the EnterMyName macro. The macro EnterMyName is shown in Listing 3.
The EnterMyName macro is not as complicated as it first appears. Learning a few things helps significantly in understanding macros. The discussion starts openoffjce features near the top of the macro listing and describes them.
All comments in macro coding begin with REM, which stands for remark. All text after REM and on the same line is ignored. As a short cut, the single quote character ' can also be used to start a comment. If you use symbolic constants defined by the Application Programming Interface APIit is safer to assume that the names are case-sensitive.
Symbolic mmacro are an advanced topic not covered by this user guide amcro are not required when using the macro recorder in LibreOffice. Individual macros are stored in subroutines and these subroutines begin how to draw a elite from halo 3 the keyword SUB.
The code starts by defining the subroutine named Main, which is empty and does nothing. The next openoffiice, EnterMyName, contains the generated code for your aa. There are advanced topics that are beyond the scope of this user guide, but knowing about them opdnoffice be port angeles ferry to victoria how long interest:.
The values macfo called arguments. However, recorded macros in LibreOffice do not accept arguments. However, recorded macros in LibreOffice always create subroutines, not functions. You can write information on a piece of paper so that you can look at it later. A variable, like a piece of paper, contains information that can be changed and read. The Dim keyword originally stood for Dimension and was used to define the dimensions of an array.
The dim statement used in the EnterMyName hwo is similar openogfice setting aside a piece of paper to be used to store a message or note. In the Openofficf macro, macroo variables document and dispatcher are defined as the type object.
Other common variable types include stringintegerand date. A third variable, named args1is an array of property values. Creaet variable of type array allows a single variable to contain multiple values, similar to storing valc pages in a single book. Values in an array are usually numbered starting from zero. The number in the parentheses indicates the what is the federal minimum wage 2015 usable number to access a storage location.
In this example, there is only one value, and it is numbered zero. The following is an explanation of the code used in the EnterMyName macro. You may not understand all the details, but the explanation of each line of code may give you some idea of how a macro works. Defines document as a variable. Objects ni a specific variable type with multiple fields representing mwcro and actions. CurrentController is a property referring to a service that crwate the document.
For example, when you type, it is the current controller that takes note of what you type. CurrentController then dispatches the changes to the document frame. Frame is a controller property that returns the main frame for a document. Most tasks in LibreOffice are accomplished by dispatching a command. LibreOffice includes a dispatch helper service, which does most of the work when using dispatches in macros. The method CreateUnoService accepts the name how to build turbojet engine a service and it tries to create an instance of that service.
Calv completion, the dispatcher variable contains a reference to a DispatchHelper. Declares an array of properties. Each property has a name and a value. The created array has one property at index zero. This is where the magic happens. The dispatch helper sends a dispatch to the document frame stored in the variable named document cteate the command.
The next two arguments, frame name and search flags, are beyond the scope of this document. The last argument is the array of property values to be used s executing the command InsertText. A common task is to copy rows and columns of data from a web site and format them as a table in a text document as follows:. With the two questions given above in mind, inspect the text to see if a macro can be recorded to format the text. The first column in this ot indicates a constant name and each name is followed by a space and a tab, and each line has two trailing spaces.
The first column in the table should contain a numeric value, the second column the name, and the third column the description. The data can be cleaned up hpw several ways, all of them easy to accomplish. The example given below uses keystrokes that assume the cursor is at the start of the line creahe the text THIN.
It takes much longer to read and write the steps than to record the macro. Work slowly and think about the steps as you do them. With practice this becomes second nature. The generated macro code in Listing 4 has been modified to contain the step number in the comments to match the code to the step above.
Cursor movements are used for all operations creaet opposed to searching. How to create a macro in openoffice calc is not perfect, but you should not run the macro on the lines that did not have the proper format. You need to do these manually. Crezte Main so that it reads as shown in Listing 5. This is very fast and easy, especially for temporary macros that will be used a few times and then discarded. Sometimes the macro recorder has a failure and understanding LibreOffice internal workings helps to understand how and why the macro recorder sometimes fails.
The primary offender is related to the dispatch framework and its relationship to the macro recorder.
Imagine repeatedly entering simple information. Although you can store the information in the clipboard, if you use the clipboard for something else, the contents are changed. Storing the contents as a macro is a simple solution. In some simple cases, including the example used here, a better solution is to use AutoText. A small window is displayed so you know that OpenOffice. Type the desired information or perform an appropriate series of operations.
In this case, I typed my name, Andrew Pitonyak. Click the Stop Recording button to stop recording, save the macro, and display the OpenOffice. Be certain to open the library container named My Macros. Find the library named Standard under My Macros.
Be warned, every library container has a library named Standard. Select the Standard library and click New Module to create a new module to contain the macro. The default module name is Module1; choose a better name. Although it is still not descriptive, I used Recorded. Type a descriptive name and click OK to create the module.
The OpenOffice. Highlight the newly created module. If you followed all of the steps, the Standard library now contains a module named Recorded, which contains the EnterMyName macro3. When OOo creates a new module, it automatically adds the macro named Main. Select the newly created macro and click Run. There are other methods to run a macro. The author, an avid macro writer, prefers the macro organizer because the dialog usually opens faster, but the selection process may be slightly slower.
You can view and edit the macro that was just created. The macro in Listing 1 is not as complicated as it first appears. Learning a few things helps significantly in understanding the generated macros. The discussion starts with features near the top of the macro listing and describes them.
The keyword REM, short for remark , starts a macro comment. All text after REM on the same line is ignored. As a short cut, the single quote character can also be used to start a comment.
Individual macros are stored in subroutines defined with the keyword SUB. The macro starts by defining the subroutine named Main, which is empty and does nothing. The next subroutine, EnterMyName, is the subroutine of interest, and it contains the newly generated code. There are advanced topics that are beyond the scope of this document, but knowing about them might be of interest:. A very simple macro can use hard coded values for everything. Unfortunately, even simple macros that interact with OpenOffice.
Storing an intermediate value is similar to writing information on a piece of paper so that you can look at it later. The DIM statement is similar to setting aside a piece of paper to be used to store a message or note.
The EnterMyName macro defines the variables document and dispatcher as type object. Other common variable types include string , integer , and date. A third variable named args1 is defined. Args1 is a very complicated type; it is an array of property values.
A variable of type array allows a single variable to contain multiple values, similar to storing multiple pages in a single book. Values in an array are usually numbered starting from zero. The number in the parentheses indicates the highest usable number to access a storage location. In this example, there is only one value, and it is numbered zero. This sounds confusing, but for now, ignore the problem and more examples will clarify the concept.
The following details are very complete; it is not important to understand all of the details. The first line defines the start of the macro. The CurrentController property of a document refers to a service that "controls" the document. For example, when you type, it is the current controller that notices.
The current controller then dispatches the changes to the document's frame. The Frame property of a controller returns a main frame for a document. Therefore, the variable named document refers to a document's frame, which receives dispatched commands.
Most tasks in OpenOffice. Starting with OOo version 2. The method CreateUnoService accepts the name of a service and it tries to create an instance of that service.
On completion, the dispatcher variable contains a reference to a DispatchHelper. Declare an array of properties. Each property has a name and a value. The created array has one property at index zero. Give the property the name "Text" and the value "Andrew Pitonyak", which is the text that is inserted when the macro is run. This is where the magic happens. The next two arguments, frame name and search flags , are beyond the scope of this document. The last argument is the array of property values to be used while executing the command InsertText.
Jump to: navigation , search. Getting Started with OpenOffice. Creating a simple macro Creating a macro Sometimes the macro recorder fails Macro organization How to run a macro Extensions Writing macros without the recorder Finding more information. DispatchHelper" rem dim args1 0 as new com. PropertyValue args1 0. If you use symbolic constants defined by the API, it is safer to assume that the names are case-sensitive—if this matters to you, then you are probably too advanced to read this document.
Content on this page is licensed under the Creative Common Attribution 3. Views Page Discussion View source History.
Personal tools Log in.