Getting Started Guide

Figure 302: Select your macro and click Run
There are other methods to run a macro. For example, use Tools > Macros >
Organize Macros > OpenOffice.org Basic to open the macro organizer, which
contains a Run button as well. Another method is to use the macro organizer; the
dialog usually opens faster, but the selection process may be slightly slower.
Viewing and editing the macro
You can view and edit the macro that was just created. Use Tools > Macros >
Organize Macros > OpenOffice.org Basic to open the OpenOffice.org Basic
Macros dialog (see Figure 302). Select the new macro and click Edit to open the
macro in the Basic IDE (Integrated Development Environment).
Listing 4: Generated “EnterMyname” macro.
REM ***** BASIC *****
Sub Main
End Sub
sub EnterMyName
rem -------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem -------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem -------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Text"
args1(0).Value = "Andrew Pitonyak"
326 Getting Started with OpenOffice.org 3.3