

Whereas in VBA the paragraphs are accessed by their number (for example, by the Paragraph(1) call), in Apache OpenOffice Basic, the Enumeration object described previously should be used. VBA : The content of the procedure described here for accessing the paragraphs of a text is comparable with the Paragraphs listing used in VBA, which is provided in the Range and Document objects available there. The text in the paragraph can be retrieved and modified using the String property: The .Paragraph service grants access to the content of a paragraph. The example uses the supportsService method to check whether the TextElement is a paragraph or a table. With the aid of Doc, the example then creates an Enumeration object that traverses through the individual parts of the text (paragraphs and tables) and assigns the current element to TextElement object. The example creates a Doc document object which references the current Apache OpenOffice document. supportsService ( ".Paragraph" ) Then MsgBox "The current block contains a paragraph." End If Wend supportsService ( ".TextTable" ) Then MsgBox "The current block contains a table." End If If TextElement. createEnumeration ' loop over all text elements While Enum. The following example traverses the contents of a text document in a loop and uses a message in each instance to inform the user whether the object in question is a paragraph or table.ĭim Doc As Object Dim Enum As Object Dim TextElement As Object ' Create document objectĭoc = ThisComponent ' Create enumeration objectĮnum = Doc. Before accessing a returned object, you should therefore check whether the returned object supports the .Paragraph service for paragraphs or the .TextTable service for tables. When working with the Enumeration object, one special scenario should, however, be noted: it not only returns paragraphs, but also tables (strictly speaking, in Apache OpenOffice Writer, a table is a special type of paragraph). The paragraphs can however be sequentially traversed with the help of the Enumeration object described in Introduction to the API. These are neither named nor indexed and there is therefore no possible way of directly accessing individual paragraphs. The core of a text document consists of a sequence of paragraphs. 1.7 Default values for character and paragraph properties.
