In OpenOffice.org, macros are grouped in modules, modules are grouped in libraries, and libraries are grouped in library containers. A library is usually used as a major grouping for either an entire category of macros, or for an entire application. Modules usually split functionality types such as user interaction and calculations. Individual macros are subroutines and functions.
Macro Library hierarchy.
A computer scientist would use the figure below to precisely describe the situation. The text “1..*” means one or more, and “0..*” means zero or more. The black triangle means composed of or contains.
- A library container contains one or more libraries, and each library is contained in one library container.
- A library contains zero or more modules, and each module is contained in one library.
- A module contains zero or more macros, and each macro is contained in one module.
Macro Library hierarchy.
Use Tools > Macros > Organize Macros > OpenOffice.org Basic to open the OpenOffice.org Basic Macros dialog. All available library containers are shown in the Macro from list. Every document is a library container, capable of containing multiple libraries. The application itself acts as two library containers, one container for macros distributed with OpenOffice.org called OpenOffice.org Macros, and one container for personal macros called My Macros. As shown below, only two documents are currently open.
Library containers are shown on the left.
The OpenOffice.org Macros are stored with the application runtime code, which may not be editable to you unless you are an administrator. This is just as well since these macros should not be changed and you should not store your own macros in the OOo container.
Unless your macros are applicable to a single document, and only to a single document, your macros will probably be stored in the My Macros container. The My Macros container is stored in your user area or home directory.
If a macro is contained in a document, then a recorded macro will attempt to work on that document; primarily because it uses “ThisComponent" for its actions.
Every library container contains a library named Standard. It is better to create your own libraries with meaningful names than to use the Standard library. Not only are meaningful names easier to manage, but they can also be imported into other library containers whereas the Standard library cannot.
| OpenOffice.org allows you to import libraries into a library container, but it will not allow you to overwrite the library named Standard. Therefore, if you store your macros in the Standard library, you cannot import them into another library container.
|
Just as it makes good sense to give your libraries meaningful names, it is prudent to use meaningful names for your modules. By default, OpenOffice.org uses names such as Module1. Feel free to use your own meaningful name.
As you create your macros, you must decide where to store them. Storing a macro in a document is useful if the document will be shared and you want the macro to be included with the document. Macros stored in the application library container named My Macros, however, are globally available to all documents.
Macros are not available until the library that contains them is loaded. The Standard library and Template library, however, are automatically loaded. A loaded library is displayed differently from a library that is not loaded. To load the library and the modules it contains, double-click on the library.