Creating a Module in a Standard Library
- Create a new Writer document and save the document, for example, FirstStepsBasic.odt.
- Click Tools > Macros > Organize Macros > OpenOffice Basic.
The OpenOffice Basic Macros dialog appears. The Macro from list shows macro containers where Basic source code (macros) can come from. There is always a My Macros and a OpenOffice Macros container for Basic libraries. Additionally each loaded document can contain Basic libraries.
The illustration above shows that the document FirstStepsBasic.odt is the only document loaded. Therefore, the My Macros, OpenOffice Macros and FirstStepsBasic.odt containers are displayed in the illustration above. Both containers, My Macros and FirstStepsBasic.odt, contain a library named Standard. The OpenOffice Macros container contains the libraries that come with a default Apache OpenOffice installation – most of them are AutoPilots. The Standard libraries of the application and for all open documents are always loaded. They appear enabled in the dialog. Other libraries have to be loaded before they can be used.
The libraries contain modules with the actual Basic source code. Our next step will create a new module for source code in the Standard library of our FirstStepsBasic.odt document.
- Scroll to the document node FirstStepsBasic.odt in the Macro from list.
- Select the Standard entry below the document node and click New.
Apache OpenOffice shows a small dialog that suggests to create a new module named Module1.
- Click to confirm.
The Basic source editor window appears containing a Sub (subroutine) Main.
The status bar of the Basic editor window shows that the Sub Main is part of FirstStepsBasic.Standard.Module1. If you click Tools > Macros > Organize Macros > OpenOffice Basic in the Basic editor, you will see that Apache OpenOffice created a module Module1 below the Standard library in FirstStepsBasic.odt.
When a module is selected, the Macro name list box on the left shows the Subs and Functions in that module. In this case, Sub Main. If you clickwhile a Sub or Function is selected, the Basic editor opens and scrolls to the selected Sub or Function.
|Content on this page is licensed under the Public Documentation License (PDL).|