OpenOffice.org OpenOffice - 3.0 Guía de inicio rápido Pagina 390

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 433
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 389
Although individual extensions can be found in different places, there
is an extension repository at: http://extensions.services.openoffice.org/.
For more about obtaining and installing extensions, see Chapter 14
(Customizing OpenOffice.org).
Writing macros without the recorder
The examples covered in this chapter are created using the macro
recorder and the dispatcher. You can also write macros that directly
access the objects that comprise OpenOffice.org. In other words, you
can directly manipulate a document.
Directly manipulating OOo’s internal objects is an advanced topic that
is beyond the scope of this chapter. A simple example, however,
demonstrates how this works.
Listing 4: Append the text “Hello” to the current document.
Sub AppendHello
Dim oDoc
Dim sTextService$
Dim oCurs
REM ThisComponent refers to the currently active document.
oDoc = ThisComponent
REM Verify that this is a text document
sTextService = "com.sun.star.text.TextDocument"
If NOT oDoc.supportsService(sTextService) Then
MsgBox "This macro only works with a text document"
Exit Sub
End If
REM Get the view cursor from the current controller.
oCurs = oDoc.currentController.getViewCursor()
REM Move the cursor to the end of the document
oCurs.gotoEnd(False)
REM Insert text "Hello" at the end of the document
oCurs.Text.insertString(oCurs, "Hello", False)
End Sub
390 Getting Started with OpenOffice.org 3
Vista de pagina 389
1 2 ... 385 386 387 388 389 390 391 392 393 394 395 ... 432 433

Comentarios a estos manuales

Sin comentarios