Storing a Macro in the Application Library


The OpenOffice.org application itself is a library container. This is an excellent place to store code and dialogs common to multiple documents. Version control is easier if macros are stored in one location. If five documents all contain the same macro, not only is storage space wasted , but if the macro changes, you must change the macro in five different documents.

To store a macro in the application libraries, use the same methods used for documents. The application-level container is named "soffice". The OpenOffice.org application includes multiple libraries. The Standard library includes a module named Module 1, which contains one empty macro that does nothing. Use the Macro Organizer dialog in Figure 3 to add new libraries.

Warning  

Uninstalling OpenOffice.org may delete libraries stored at the application level, so you should always keep a backup of your libraries. Reinstalling or installing a new version of OpenOffice.org may overwrite application-level libraries. Back up these libraries when you back up your documents. In most cases, the libraries that you created are still there, but the configuration files are new and do not reflect the new libraries. Therefore, it's usually possible to restore your libraries from the standard library location. For more information, see the section titled "Library management," later in this chapter.

Each application library is stored in its own directory. To determine where OpenOffice.org stores application libraries, select Tools Options. In the Options dialog, expand the OpenOffice.org branch in the tree menu and select Paths. The Basic entry shows the locations of the external libraries.

Before installing a new version of OpenOffice.org, make a copy of all application-level libraries. If you install OOo into the same location, it overwrites the configuration file that tells OOo where your application-level libraries are. The libraries are usually still there but OOo does not know about them. To restore lost libraries, regardless of where they are located, use the Libraries tab on the Macro Organizer (see Figure 3). Verify that "soffice" is selected in the Application/Document list, and then click the Append button. Navigate to the directory containing the library that you want to add. Select the file script.xlb and click Open . Do this for each library that you want to restore. This method can also be used to add libraries stored in documents.

Tip  

Do not use the Standard library if you think you'll ever want to append your library to another location. Store all of your modules in libraries with meaningful names that you create. The Standard library is special, and you cannot delete it or overwrite it.

To practice adding a macro to the application-level library, open the Macro Organizer. Verify that the "sofffce" library container is the current container. Click the New Module button to add new modules to the application-level libraries. To add new libraries, select the Libraries tab. Verify that "soffice" is selected in the Application/Document list, and then click the New button.

Libraries stored in documents may be appended to the application library container. When a library is appended, it overwrites an existing library with the same name . It is, therefore, a good idea to create meaningful library names to hold macros. This limits problems moving macros between library containers.




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