VisualBasic scripting in LibreOffice

 Here an example to run in Writer:

Sub Hello
Dim oDoc
Dim sTextService$
Dim oCurs
REM ThisComponent se refiere al documento actualmente activo
oDoc = ThisComponent
REM Verifica que este es un documento de texto
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 obtiene la vista del cursor del controlador actual
oCurs = oDoc.currentController.getViewCursor()
REM Mueve el cursor al final del documento
oCurs.gotoEnd(False)
REM Inserta el texto “Hola” al final del documento
oCurs.Text.insertString(oCurs, "Hello World", False)
End Sub
REM https://documentation.libreoffice.org/assets/Uploads/Documentation/es/GS52/PDF/GS5213-PrimerosPasosConMacros.pdf

And the result is here:



Comments

Popular posts from this blog

How to fix Android when developer options are not available for this user

Contiki 3.0 on XM1000

How to fix VirtualBox error when you try to import an ova file