<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Psequeirag</id>
	<title>Apache OpenOffice Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openoffice.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Psequeirag"/>
	<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/wiki/Special:Contributions/Psequeirag"/>
	<updated>2026-11-24T01:05:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.14</generator>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Error_Handling&amp;diff=161465</id>
		<title>Documentation/BASIC Guide/Error Handling</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Error_Handling&amp;diff=161465"/>
		<updated>2010-03-29T13:08:18Z</updated>

		<summary type="html">&lt;p&gt;Psequeirag: Correct description of the Err variable.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/Procedures and Functions&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/Other Instructions&lt;br /&gt;
|lang=block&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Error Handling}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
Correct handling of error situations is one of the most time-consuming tasks of programming. {{OOo}} Basic provides a range of tools for simplifying error handling.&lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;On Error&amp;lt;/tt&amp;gt; Instruction ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;On Error&amp;lt;/tt&amp;gt; instruction is the key to any error handling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Sub Test&lt;br /&gt;
  On Error Goto ErrorHandler&lt;br /&gt;
  &amp;#039; ... undertake task during which an error may occur&lt;br /&gt;
  Exit Sub&lt;br /&gt;
  ErrorHandler: &lt;br /&gt;
    &amp;#039; ... individual code for error handling&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;On Error Goto ErrorHandler&amp;lt;/tt&amp;gt; line defines how {{OOo}} Basic proceeds in the event of an error. The &amp;lt;tt&amp;gt;Goto ErrorHandler&amp;lt;/tt&amp;gt; ensures that {{OOo}} Basic exits the current program line and then executes the &amp;lt;tt&amp;gt;ErrorHandler:&amp;lt;/tt&amp;gt; code. &lt;br /&gt;
&lt;br /&gt;
== The &amp;lt;tt&amp;gt;Resume&amp;lt;/tt&amp;gt; Command ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;Resume Next&amp;lt;/tt&amp;gt; command continues the program from the line that follows where the error occurred in the program after the code in the error handler has been executed:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
ErrorHandler:&lt;br /&gt;
  &amp;#039; ... individual code for error handling&lt;br /&gt;
  Resume Next&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;tt&amp;gt;Resume Proceed&amp;lt;/tt&amp;gt; command to specify a jump point for continuing the program after error handling:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
ErrorHandler:&lt;br /&gt;
  &amp;#039; ... individual code for error handling&lt;br /&gt;
  Resume Proceed&lt;br /&gt;
 &lt;br /&gt;
Proceed:&lt;br /&gt;
  &amp;#039; ... the program continues here after the error&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The term Proceed is a label. It could be for example, A247. The syntax for label names is the same as for variable names.&lt;br /&gt;
 &lt;br /&gt;
To continue a program without an error message when an error occurs, use the following format: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Sub Test&lt;br /&gt;
  On Error Resume Next&lt;br /&gt;
  &amp;#039; ... perform task during which an error may occur&lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use the &amp;lt;tt&amp;gt;On Error Resume Next&amp;lt;/tt&amp;gt; command with caution as its effect is global.&lt;br /&gt;
&lt;br /&gt;
== Queries Regarding Error Information ==&lt;br /&gt;
&lt;br /&gt;
In error handling, it is useful to have a description of the error and to know where and why the error occurred:&lt;br /&gt;
&lt;br /&gt;
* The &amp;lt;tt&amp;gt;Err&amp;lt;/tt&amp;gt; variable contains a number identifying the type of error that has occurred.&lt;br /&gt;
* The &amp;lt;tt&amp;gt;Error$&amp;lt;/tt&amp;gt; variable contains a description of the error.&lt;br /&gt;
* The &amp;lt;tt&amp;gt;Erl&amp;lt;/tt&amp;gt; variable contains the line number where the error occurred. &lt;br /&gt;
&lt;br /&gt;
The call&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
 MsgBox &amp;quot;Error &amp;quot; &amp;amp; Err &amp;amp; &amp;quot;: &amp;quot; &amp;amp; Error$ &amp;amp; &amp;quot; (line : &amp;quot; &amp;amp; Erl &amp;amp; &amp;quot;)&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
shows how the error information can be displayed in a message window. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/VBAnote|Whereas VBA summarizes the error messages in a global object called &amp;lt;tt&amp;gt;Err&amp;lt;/tt&amp;gt;, {{OOo}} Basic provides the &amp;lt;tt&amp;gt;Err,&amp;lt;/tt&amp;gt; &amp;lt;tt&amp;gt;Error$&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Erl&amp;lt;/tt&amp;gt; variables.}}&lt;br /&gt;
&lt;br /&gt;
The status information remains valid until the program encounters a &amp;lt;tt&amp;gt;Resume&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;On Error&amp;lt;/tt&amp;gt; command, whereupon the information is reset. &lt;br /&gt;
&lt;br /&gt;
{{Documentation/VBAnote|In VBA, the &amp;lt;tt&amp;gt;Err.Clear&amp;lt;/tt&amp;gt; method of the &amp;lt;tt&amp;gt;Err&amp;lt;/tt&amp;gt; object resets the error status after an error occurs. In {{OOo}} Basic, this is accomplished with the &amp;lt;tt&amp;gt;On Error&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;Resume&amp;lt;/tt&amp;gt; commands. }}&lt;br /&gt;
&lt;br /&gt;
== Tips for Structured Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Both the definition command, &amp;lt;tt&amp;gt;On Error&amp;lt;/tt&amp;gt;, and the return command, &amp;lt;tt&amp;gt;Resume&amp;lt;/tt&amp;gt;, are variants of the &amp;lt;tt&amp;gt;Goto&amp;lt;/tt&amp;gt; construct.&lt;br /&gt;
&lt;br /&gt;
If you want to cleanly structure your code to prevent generating errors when you use this construct, you should not use jump commands without monitoring them.&lt;br /&gt;
&lt;br /&gt;
Care should be taken when you use the &amp;lt;tt&amp;gt;On Error Resume Next&amp;lt;/tt&amp;gt; command as this dismisses all open error messages.&lt;br /&gt;
&lt;br /&gt;
The best solution is to use only one approach for error handling within a program - keep error handling separate from the actual program code and do not jump back to the original code after the error occurs.&lt;br /&gt;
&lt;br /&gt;
The following code is an example of an error handling procedure:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Sub Example&lt;br /&gt;
  &amp;#039; Define error handler at the start of the function &lt;br /&gt;
  On Error Goto ErrorHandler   &lt;br /&gt;
    &amp;#039; ... Here is the actual program code&lt;br /&gt;
  On Error Goto 0           &amp;#039; Deactivate error handling&lt;br /&gt;
    &amp;#039; End of regular program implementation&lt;br /&gt;
  Exit Sub&lt;br /&gt;
&lt;br /&gt;
 &amp;#039; Start point of error handling&lt;br /&gt;
 ErrorHandler:                &lt;br /&gt;
   &amp;#039; Check whether error was expected&lt;br /&gt;
    If Err = ExpectedErrorNo Then   &lt;br /&gt;
      &amp;#039; ... Process error&lt;br /&gt;
    Else&lt;br /&gt;
      &amp;#039; ... Warning of unexpected error&lt;br /&gt;
    End If&lt;br /&gt;
 On Error Goto 0            &amp;#039; Deactivate error handling &lt;br /&gt;
End Sub&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This procedure begins with the definition of an error handler, followed by the actual program code. At the end of the program code, the error handling is deactivated by the &amp;lt;tt&amp;gt;On Error Goto 0&amp;lt;/tt&amp;gt; call and the procedure implementation is ended by the &amp;lt;tt&amp;gt;Exit Sub&amp;lt;/tt&amp;gt; command (not to be confused with &amp;lt;tt&amp;gt;End Sub&amp;lt;/tt&amp;gt;). &lt;br /&gt;
&lt;br /&gt;
The example first checks if the error number corresponds to the expected number (as stored in the imaginary &amp;lt;tt&amp;gt;ExpectedErrorNo&amp;lt;/tt&amp;gt; constant) and then handles the error accordingly. If another error occurs, the system outputs a warning. It is important to check the error number so that unanticipated errors can be detected.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;On Error Goto 0&amp;lt;/tt&amp;gt; call at the end of the code resets the status information of the error (the error code in the &amp;lt;tt&amp;gt;Err&amp;lt;/tt&amp;gt; system variables) so that an error occurring at a later date can be clearly recognized.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Error Handling}}&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Psequeirag</name></author>
	</entry>
	<entry>
		<id>https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Interface_Overview&amp;diff=159735</id>
		<title>Documentation/BASIC Guide/Interface Overview</title>
		<link rel="alternate" type="text/html" href="https://wiki.openoffice.org/w/index.php?title=Documentation/BASIC_Guide/Interface_Overview&amp;diff=159735"/>
		<updated>2010-03-21T05:51:21Z</updated>

		<summary type="html">&lt;p&gt;Psequeirag: Corrected XNamedAccess to XNameAccess&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Documentation/BASICGuideTOC/v2&lt;br /&gt;
|ShowPrevNext=block&lt;br /&gt;
|ShowPrevPage=block&lt;br /&gt;
|PrevPage=Documentation/BASIC Guide/UNO Tools&lt;br /&gt;
|NextPage=Documentation/BASIC Guide/Documents&lt;br /&gt;
|api=block&lt;br /&gt;
}}&lt;br /&gt;
{{DISPLAYTITLE:Overview of Some Central Interfaces}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
Some interfaces of {{OOo}} can be found in many parts of the {{OOo}} API. They define sets of methods for abstract tasks which can be applied to various problems. Here, you will find an overview of the most common of these interfaces. &lt;br /&gt;
&lt;br /&gt;
The origin of the objects is explained at a later point in this guide. At this point, only some of the abstract aspects of objects, for which the {{OOo}} API provides some central interfaces, are discussed.&lt;br /&gt;
&lt;br /&gt;
== Creating Context-Dependent Objects ==&lt;br /&gt;
&lt;br /&gt;
The {{OOo}} API provides two options for creating objects. One can be found in the &amp;lt;tt&amp;gt;createUnoService&amp;lt;/tt&amp;gt; function mentioned at the start of this chapter. &amp;lt;tt&amp;gt;createUnoService&amp;lt;/tt&amp;gt; creates an object which can be used universally. Such objects and services are also known as context-independent services. &lt;br /&gt;
&lt;br /&gt;
In addition to context-independent services, there are also context-dependent services whose objects are only useful when used in conjunction with another object. A drawing object for a spreadsheet document, for example, can therefore only exist in conjunction with this one document.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;com.sun.star.lang.XMultiServiceFactory&amp;lt;/tt&amp;gt; Interface ===&lt;br /&gt;
&lt;br /&gt;
Context-dependent objects are usually created by means of an object method, on which the object depends. The &amp;lt;tt&amp;gt;createInstance&amp;lt;/tt&amp;gt; method, which is defined in the &amp;lt;tt&amp;gt;XMultiServiceFactory&amp;lt;/tt&amp;gt; interface, is used in particular in the document objects. &lt;br /&gt;
&lt;br /&gt;
The drawing object can, for example, be created as follows using a spreadsheet object: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim RectangleShape As Object&lt;br /&gt;
RectangleShape = _&lt;br /&gt;
  Spreadsheet.createInstance(&amp;quot;com.sun.star.drawing.RectangleShape&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A paragraph template in a text document is created in the same way: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Style as Object&lt;br /&gt;
Style = Textdocument.createInstance(&amp;quot;com.sun.star.style.ParagraphStyle&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Named Access to Subordinate Objects ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;XNameAccess&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;XNameContainer&amp;lt;/tt&amp;gt; interfaces are used in objects that contain subordinate objects, which can be addressed using a natural language name. &lt;br /&gt;
&lt;br /&gt;
While &amp;lt;tt&amp;gt;XNameAccess&amp;lt;/tt&amp;gt; permits access to the individual objects, &amp;lt;tt&amp;gt;XNameContainer&amp;lt;/tt&amp;gt; takes on the insertion, modification and deletion of elements.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;com.sun.star.container.XNameAccess&amp;lt;/tt&amp;gt; Interface ===&lt;br /&gt;
&lt;br /&gt;
An example of the use of &amp;lt;tt&amp;gt;XNameAccess&amp;lt;/tt&amp;gt; is provided by the &amp;lt;tt&amp;gt;sheets&amp;lt;/tt&amp;gt; object of a spreadsheet. It combines all the pages within the spreadsheet. The individual pages are accessed from the &amp;lt;tt&amp;gt;sheets&amp;lt;/tt&amp;gt; object, by using the &amp;lt;tt&amp;gt;getByName&amp;lt;/tt&amp;gt; method from &amp;lt;tt&amp;gt;XNameAccess&amp;lt;/tt&amp;gt;: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Sheets As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
&lt;br /&gt;
Sheets = Spreadsheet.Sheets&lt;br /&gt;
Sheet = Sheets.getByName(&amp;quot;Sheet1&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;getElementNames&amp;lt;/tt&amp;gt; method provides an overview of the names of all elements. As a result, it returns a data field containing the names. The following example shows how all element names of a spreadsheet can thereby be determined and displayed in a loop: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Sheets As Object&lt;br /&gt;
Dim SheetNames&lt;br /&gt;
Dim I As Integer&lt;br /&gt;
&lt;br /&gt;
Sheets = Spreadsheet.Sheets&lt;br /&gt;
SheetNames = Sheets.getElementNames&lt;br /&gt;
&lt;br /&gt;
For I=LBound(SheetNames) To UBound(SheetNames)&lt;br /&gt;
  MsgBox SheetNames(I)&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;hasByName&amp;lt;/tt&amp;gt; method of the &amp;lt;tt&amp;gt;XNameAccess&amp;lt;/tt&amp;gt; interface reveals whether a subordinate object with a particular name exists within the basic object. The following example therefore displays a message that informs the user whether the &amp;lt;tt&amp;gt;Spreadsheet&amp;lt;/tt&amp;gt; object contains a page of the name &amp;lt;tt&amp;gt;Sheet1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Sheets As Object&lt;br /&gt;
&lt;br /&gt;
Sheets = Spreadsheet.Sheets&lt;br /&gt;
If Sheets.HasByName(&amp;quot;Sheet1&amp;quot;) Then&lt;br /&gt;
  MsgBox &amp;quot; Sheet1 available&amp;quot;&lt;br /&gt;
Else&lt;br /&gt;
  MsgBox &amp;quot;Sheet1 not available&amp;quot;&lt;br /&gt;
End If&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;com.sun.star.container.XNameContainer&amp;lt;/tt&amp;gt; Interface ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;XNameContainer&amp;lt;/tt&amp;gt; interface takes on the insertion, deletion and modification of subordinate elements in a basic object. The functions responsible are &amp;lt;tt&amp;gt;insertByName&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;removeByName&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;replaceByName&amp;lt;/tt&amp;gt;. &lt;br /&gt;
&lt;br /&gt;
The following is a practical example of this. It calls a text document, which contains a &amp;lt;tt&amp;gt;StyleFamilies&amp;lt;/tt&amp;gt; object and uses this to in turn make the paragraph templates (ParagraphStyles) of the document available. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim StyleFamilies As Object&lt;br /&gt;
Dim ParagraphStyles As Object&lt;br /&gt;
Dim NewStyle As Object   &lt;br /&gt;
&lt;br /&gt;
StyleFamilies = Textdoc.StyleFamilies&lt;br /&gt;
ParagraphStyles = StyleFamilies.getByName(&amp;quot;ParagraphStyles&amp;quot;)&lt;br /&gt;
ParagraphStyles.insertByName(&amp;quot;NewStyle&amp;quot;, NewStyle)      &lt;br /&gt;
ParagraphStyles.replaceByName(&amp;quot;ChangingStyle&amp;quot;, NewStyle)   &lt;br /&gt;
ParagraphStyles.removeByName(&amp;quot;OldStyle&amp;quot;)            &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;insertByName&amp;lt;/tt&amp;gt; line inserts the &amp;lt;tt&amp;gt;NewStyle&amp;lt;/tt&amp;gt; style under the name of the same name in the &amp;lt;tt&amp;gt;ParagraphStyles&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;replaceByName&amp;lt;/tt&amp;gt; line changes the object behind &amp;lt;tt&amp;gt;ChangingStyle&amp;lt;/tt&amp;gt; into &amp;lt;tt&amp;gt;NewStyle&amp;lt;/tt&amp;gt;. Finally, the &amp;lt;tt&amp;gt;removeByName&amp;lt;/tt&amp;gt; call removes the object behind &amp;lt;tt&amp;gt;OldStyle&amp;lt;/tt&amp;gt; from &amp;lt;tt&amp;gt;ParagraphStyles&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Index-Based Access to Subordinate Objects ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;XIndexAccess&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;XIndexContainer&amp;lt;/tt&amp;gt; interfaces are used in objects which contain subordinate objects and which can be addressed using an index. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;XIndexAccess&amp;lt;/tt&amp;gt; provides the methods for accessing individual objects. &amp;lt;tt&amp;gt;XIndexContainer&amp;lt;/tt&amp;gt; provides methods for inserting and removing elements.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;com.sun.star.container.XIndexAccess&amp;lt;/tt&amp;gt; Interface ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;tt&amp;gt;XIndexAccess&amp;lt;/tt&amp;gt; provides the &amp;lt;tt&amp;gt;getByIndex&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;getCount&amp;lt;/tt&amp;gt; methods for calling the subordinate objects. &amp;lt;tt&amp;gt;getByIndex&amp;lt;/tt&amp;gt; provides an object with a particular index. &amp;lt;tt&amp;gt;getCount&amp;lt;/tt&amp;gt; returns how many objects are available. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim Sheets As Object&lt;br /&gt;
Dim Sheet As Object&lt;br /&gt;
Dim I As Integer&lt;br /&gt;
&lt;br /&gt;
Sheets = Spreadsheet.Sheets&lt;br /&gt;
&lt;br /&gt;
For I = 0 to Sheets.getCount() - 1&lt;br /&gt;
  Sheet = Sheets.getByIndex(I)&lt;br /&gt;
  &amp;#039; Editing sheet&lt;br /&gt;
Next I&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example shows a loop that runs through all sheet elements one after another and saves a reference to each in the &amp;lt;tt&amp;gt;Sheet&amp;lt;/tt&amp;gt; object variable. When working with the indexes, note that &amp;lt;tt&amp;gt;getCount&amp;lt;/tt&amp;gt; returns the number of elements. The elements in &amp;lt;tt&amp;gt;getByIndex&amp;lt;/tt&amp;gt; however are numbered beginning with 0. The counting variable of the loop therefore runs from 0 to &amp;lt;tt&amp;gt;getCount()-1&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;com.sun.star.container.XIndexContainer&amp;lt;/tt&amp;gt; Interface ===&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;XIndexContainer&amp;lt;/tt&amp;gt; interface provides the &amp;lt;tt&amp;gt;insertByIndex&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;removeByIndex&amp;lt;/tt&amp;gt; functions. The parameters are structured in the same way as the corresponding functions in &amp;lt;tt&amp;gt;XNameContainer&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Iterative Access to Subordinate Objects ==&lt;br /&gt;
&lt;br /&gt;
In some instances, an object may contain a list of subordinate objects that cannot be addressed by either a name or an index. In these situations, the &amp;lt;tt&amp;gt;XEnumeration&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;XenumerationAccess&amp;lt;/tt&amp;gt; interfaces are appropriate. They provide a mechanism through which all subordinate elements of an objects can be passed, step by step, without having to use direct addressing. &lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;tt&amp;gt;com.sun.star.container.XEnumeration&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;XenumerationAccess&amp;lt;/tt&amp;gt; Interfaces ===&lt;br /&gt;
&lt;br /&gt;
The basic object must provide the &amp;lt;tt&amp;gt;XEnumerationAccess&amp;lt;/tt&amp;gt; interface, which contains only a &amp;lt;tt&amp;gt;createEnumeration&amp;lt;/tt&amp;gt; method. This returns an auxiliary object, which in turn provides the &amp;lt;tt&amp;gt;XEnumeration&amp;lt;/tt&amp;gt; interface with the &amp;lt;tt&amp;gt;hasMoreElements&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;nextElement&amp;lt;/tt&amp;gt; methods. Through these, you then have access to the subordinate objects. &lt;br /&gt;
&lt;br /&gt;
The following example steps through all the paragraphs of a text:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;oobas&amp;quot;&amp;gt;&lt;br /&gt;
Dim ParagraphEnumeration As Object&lt;br /&gt;
Dim Paragraph As Object&lt;br /&gt;
&lt;br /&gt;
ParagraphEnumeration = Textdoc.Text.createEnumeration&lt;br /&gt;
&lt;br /&gt;
While ParagraphEnumeration.hasMoreElements()&lt;br /&gt;
  Paragraph = ParagraphEnumeration.nextElement()&lt;br /&gt;
Wend&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The example first creates a &amp;lt;tt&amp;gt;ParagraphEnumeration&amp;lt;/tt&amp;gt; auxiliary object. This gradually returns the individual paragraphs of the text in a loop. The loop is terminated as soon as the &amp;lt;tt&amp;gt;hasMoreElements&amp;lt;/tt&amp;gt; method returns the &amp;lt;tt&amp;gt;False&amp;lt;/tt&amp;gt; value, signaling that the end of the text has been reached.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
{{InterWiki Languages BasicGuide|articletitle=Documentation/BASIC Guide/Interface Overview}}&lt;br /&gt;
{{PDL1}}&lt;/div&gt;</summary>
		<author><name>Psequeirag</name></author>
	</entry>
</feed>