OpenOffice.org OpenOffice - 3.0 Quick Start Guide Page 375

  • Download
  • Add to my manuals
  • Print
  • Page
    / 433
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 374
10) Press
Backspace
twice to remove the two trailing spaces.
11) Press
Home
to move the cursor to the start of the line.
12) Press
Ctrl+V
to paste the selected number to the start of the line.
13) Pasting the value also pasted an extra space, so press
Backspace
to remove the extra space.
14) Press
Tab
to insert a tab between the number and the name.
15) Press
Home
to move to the start of the line.
16) Press
down arrow
to move to the next line.
17) Stop recording the macro and save the macro.
It takes much longer to read and write the steps than to record the
macro. Work slowly and think about the steps as you do them. With
practice this becomes second nature.
The generated macro has been modified to contain the step number in
the comments to match the code to the step above.
Listing 2: Copy the numeric value to the start of the column.
sub CopyNumToCol1
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 (2) Press Ctrl+Right Arrow to move the cursor to the start of “specifies”.
dispatcher.executeDispatch(document, ".uno:GoToNextWord", "", 0, Array())
rem (3) Press Backspace twice to remove the tab and the space.
dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array())
rem -------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:SwBackspace", "", 0, Array())
rem (4) Press Tab to add the tab without the space after the constant name.
dim args4(0) as new com.sun.star.beans.PropertyValue
args4(0).Name = "Text"
args4(0).Value = CHR$(9)
dispatcher.executeDispatch(document, ".uno:InsertText", "", 0, args4())
rem (5) Press Delete to delete the lower case s ....
dispatcher.executeDispatch(document, ".uno:Delete", "", 0, Array())
rem (5) ... and then press S to add an upper case S.
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "Text"
args6(0).Value = "S"
Chapter 13 Getting Started with Macros 375
Page view 374
1 2 ... 370 371 372 373 374 375 376 377 378 379 380 ... 432 433

Comments to this Manuals

No comments