Operation Manual

rem (12) Press Home to move the cursor to the start of the line.
dispatcher.executeDispatch(document, ".uno:GoToStartOfLine", "", 0, Array())
rem (13) Press Ctrl+V to paste the selected number to the start of the line.
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())
rem (14) Press Backspace to remove the extra space.
dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array())
rem (15) Press Tab to insert a tab between the number and the name.
dim args17(0) as new com.sun.star.beans.PropertyValue
args17(0).Name = "Text"
args17(0).Value = CHR$(9)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args17())
rem (16) Press Home to move to the start of the line.
dispatcher.executeDispatch(document, ".uno:GoToStartOfLine", "", 0, Array())
rem (17) Press Down Arrow to move to the next line.
dim args19(1) as new com.sun.star.beans.PropertyValue
args19(0).Name = "Count"
args19(0).Value = 1
args19(1).Name = "Select"
args19(1).Value = false
dispatcher.executeDispatch(document, ".uno:GoDown", "", 0, args19())
end sub
Cursor movements are used for all operations (as opposed to searching). If run on the
DONTKNOW line, the word weight is moved to the front of the line, and the first “The” is changed
to “She”. This is not perfect, but you should not run the macro on the lines that did not have the
proper format. You need to do these manually.
Running a macro quickly
It is tedious to repeatedly run the macro using Tools > Macros > Run Macro on the main menu
bar when the macro can be run from the IDE (Figure 334 on page 344).
1) Go to Tools > Macros > Organize Macros > LibreOffice Basic on the main menu bar to
open the Basic Macro dialog (Figure 332 on page 343).
2) Select your macro and click Edit to open the macro in the IDE.
3) Click the Run BASIC icon on the Macro toolbar, or press the F5 key, to run the macro.
4) Unless you change the first macro, it is the empty macro named Main. Modify Main so that
it reads as shown in Listing 5.
5) Now, you can run CopyNumToCol1 by repeatedly clicking the Run Basic icon in the toolbar
of the IDE. This is very fast and easy, especially for temporary macros that will be used a
few times and then discarded.
Listing 5: Modify Main to call CopyNumToCol1.
Sub Main
CopyNumToCol1
End Sub
Chapter 13 Getting Started with Macros | 351