Chapter 1: Getting Started


Overview

In OpenOffice.org, macros and dialogs are stored in documents and libraries. The included integrated development environment (IDE) is used to create and debug macros. This chapter introduces the basic concepts of starting the IDE and creating macros by showing the steps to produce a simple macro, which displays the text "Hello World" on the screen.

A macro is a saved sequence of commands or keystrokes that are stored for later use. An example of a simple macro is one that "types" your address. Macros support commands that allow a variety of advanced functions, such as making decisions (for example, if the balance is less than zero, color it red; if not, color it black), looping (if the balance is greater than zero, subtract 10 from it), and even interacting with a person (asking the user for a number). Some of these commands are based on the BASIC programming language. (BASIC is an acronym for Beginner's All-purpose Symbolic Instruction Code.) It is common to assign a macro to a keystroke or toolbar icon so that it can be quickly started.

The OpenOffice.org macro language is very flexible, allowing automation of both simple and complex tasks . Although writing macros and learning about the inner workings of OpenOffice.org can be a lot of fun, it is not always the best approach. Macros are especially useful when you have to do a task the same way over and over again, or when you want to press a single button to do something that normally takes several steps. Once in a while you might write a macro to do something you can't otherwise do in OpenOffice.org, but in that case you should investigate thoroughly to be sure OOo cannot do it. For instance, a common request on some of the OpenOffice.org mailing lists is for a macro that removes empty paragraphs. This functionality is provided with AutoFormat (select Tools AutoCorrect/AutoFormat Options tab). It is also possible to use regular expressions to search for and replace empty space. There is a time and a purpose for macros and a time for other solutions. This chapter will begin to prepare you for the times when a macro is the solution of choice.

Note  

OpenOffice.org is abbreviated as OOo. "OpenOffice.org Basic" is therefore abbreviated as "OOo Basic."

The OpenOffice.org macro language is based on the BASIC programming language. OOo Basic runs one line at a time. However, you usually need more than one line to get anything done, so you will typically write routines-also known as procedures-that consist of a number of lines that, when all are run, do a particular thing. For instance, you might write a routine that deletes a header from a file and inserts your preferred header. In OpenOffice.org, routines that are logically related are stored in a module. For example, a module might contain routines for finding common mistakes that require editing. Logically related modules are stored in a library, and libraries are stored in library containers. The OpenOffice.org application can act as a library container, as can any OOo document. Simply stated, the OpenOffice.org application and every OpenOffice.org document can contain libraries, modules, and macros.

Note  

A dialog is a window that appears on the screen, usually to request input or present information. Dialogs usually disappear after the requested input is entered. User-created dialogs are stored in dialog libraries in the same way that macros are stored in macro libraries. Each library can contain multiple dialogs. Library containers can store both macro and dialog libraries. See Chapter 17, "Dialogs and Controls," for more about dialogs.




OpenOffice.org Macros Explained
OpenOffice.org Macros Explained
ISBN: 1930919514
EAN: 2147483647
Year: 2004
Pages: 203

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net