![]() | This article includes alist of references,related reading, orexternal links,but its sources remain unclear because it lacksinline citations. Please helpimprove this article byintroducing more precise citations.(December 2013) (Learn how and when to remove this message) |
OpenOffice Basic (formerly known as StarOffice Basic orStarBasic orOOoBasic) is a dialect of theprogramming languageBASIC that originated with theStarOfficeoffice suite and spread throughOpenOffice.org and derivatives such asApache OpenOffice andLibreOffice (where it is known asLibreOffice Basic). The language is adomain-specific programming language which specifically serves the OpenOffice application suite.
Although OpenOffice Basic is similar to other dialects of BASIC, such asMicrosoft'sVisual Basic for Applications (VBA), theapplication programming interface (API) is very different, as the example below of amacro illustrates. While there is a much easier way to obtain the "paragraph count" document property, the example shows the fundamental methods for accessing each paragraph in a text document, sequentially.
SubParaCount'' Count number of paragraphs in a text document'DimDocAsObject,EnumAsObject,TextElAsObject,CountAsLongDoc=ThisComponent' Is this a text document?IfNotDoc.SupportsService("com.sun.star.text.TextDocument")ThenMsgBox"This macro must be run from a text document",64,"Error"ExitSubEndIfCount=0' Examine each component - paragraph or table?Enum=Doc.Text.CreateEnumerationWhileEnum.HasMoreElementsTextEl=Enum.NextElement' Is the component a paragraph?IfTextEl.SupportsService("com.sun.star.text.Paragraph")ThenCount=Count+1EndIfWend'Display resultMsgBoxCount,0,"Paragraph Count"EndSub