StarOffice Basic
StarOffice Basic (also known as StarBasic and OOoBasic ) is a BASIC dialect that is integrated into the LibreOffice , OpenOffice.org and StarOffice office packages and the IBM Lotus Symphony based on them .
Comparison with other basic dialects
StarBasic is similar to other Basic dialects such as Microsoft's VBA . In practice, a macro in StarBasic usually requires a greater overhead than a macro in the corresponding Microsoft application with the same functionality. In the following, a macro for the Writer ( word processing program ) from OpenOffice is shown above, below the macro with the same function - namely counting the sections of a text document - in VBA from Microsoft Word :
Sub ParaCount
'
' Absätze in einem Textdokument zählen in OpenOffice Basic
'
Dim Doc As Object, Enum As Object, Count As Long
Doc = ThisComponent
' Ist dies ein Textdokument?
If Not Doc.SupportsService("com.sun.star.text.TextDocument") Then
MsgBox "Dieses Makro muss aus einem Textdokument ausgeführt werden", 64, "Error"
Exit Sub
End If
Count = 0
' Jeden Teil des Dokuments überprüfen - Absatz oder Tabelle?
Enum = Doc.Text.CreateEnumeration
While Enum.HasMoreElements
TextEl = Enum.NextElement
' Ist dieser Teil des Dokuments ein Absatz?
If TextEl.SupportsService("com.sun.star.text.Paragraph") Then
Count = Count + 1
End If
Wend
'Ergebnis anzeigen:
MsgBox Count, 0, "Anzahl der Absätze"
End Sub
Sub ParaCount()
'
' Absätze in einem Textdokument zählen in MS Word Visual Basic
'
MsgBox ActiveDocument.Paragraphs.Count
End Sub
literature
- Thomas Krumbein: Macro Cookbook. LibreOffice / OpenOffice Basic , Tintal Verlag, Wiesbaden 2013, ISBN 978-3-9437-7102-2 .
Web links
BASIC macros
- Programming manual StarOffice 7 Basic
- StarOffice 8 programming manual for BASIC 8 ( Memento from March 30, 2009 in the Internet Archive ) (PDF; 1.6 MB)
- OpenOffice.org VBA Emulation Model Project (in an early development phase)
- Andrew Pitonyak's macro information
- Step-by-step instructions for integrating a basic macro in Calc