PDF Getting Started with Macros

Getting Started with Macros:

Extract from " Macros Explained"

Title:

Getting Started with Macros: Extract from " Macros

Explained"

Version: 1.0

First edition: January 2005

First English

edition:

January 2005

Contents

Overview..........................................................................................................................................ii Copyright and trademark information.........................................................................................ii Feedback.....................................................................................................................................ii Acknowledgments.......................................................................................................................ii Modifications and updates..........................................................................................................ii

The macro language...............................................................................................3 Storing a macro in a document library.............................................................................................4

Step 1. Create a library................................................................................................................4 Step 2. Create a module...............................................................................................................7 Step 3. Enter your first macro.....................................................................................................9 Storing a macro in the application library......................................................................................13 The Integrated Development Environment....................................................................................14 Using breakpoints......................................................................................................................18 Library management......................................................................................................................19 How libraries are stored............................................................................................................19 Application libraries..................................................................................................................19 Document libraries....................................................................................................................21 Using the Macro Organizer.......................................................................................................22 Renaming modules and libraries....................................................................................................23 Adding libraries.............................................................................................................................24 Conclusion.....................................................................................................................................26

Getting Started with Macros

i

Overview

Overview

In , 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.

Copyright and trademark information

The contents of this Documentation are subject to the Public Documentation License, Version 1.0 (the "License"); you may only use this Documentation if you comply with the terms of this License. A copy of the License is available at: .

The Original Documentation is Getting Started with Macros: Extract from " Macros Explained". The Initial Writer of the Original Documentation is Andrew Douglas Pitonyak ? 2004. All Rights Reserved. (Initial Writer contact: andrew@. Contact the Initial Writer(s) only to report errors in the documentation. For questions regarding how to use the software, subscribe to the Users Mail List and post your question there: .)

All trademarks within this guide belong to legitimate owners.

Feedback

Please direct any comments or suggestions about this document to: authors@user-faq..

Acknowledgments

This chapter is reprinted, with the permission of the author and the publisher, from Chapter 1 of Andrew Pitonyak's book Macros Explained, published by Hentzenwerke, 2004. More information about the book, including a table of contents, is available from .

Modifications and updates

Version 1.0

Date 17 Jan 2005

Description of Change First published edition in this format.

Getting Started with Macros

ii

The macro language

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 macro language is very flexible, allowing automation of both simple and complex tasks. Although writing macros and learning about the inner workings of 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 , but in that case you should investigate thoroughly to be sure OOo cannot do it. For instance, a common request on some of the 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

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

The 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 , 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 application can act as a library container, as can any OOo document. Simply stated, the application and every 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. Usercreated 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" in Macros Explained for more about dialogs.

Getting Started with Macros

3

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download