Halle Andrew,
again thank you for your answer.
I got twice the answer 1 for the printing calls. I interpret this that I
have two sheets, namely sheet 0 and sheet 1. As long as I had oo0 2.0, I had
no problem. I handled 10 tables in one macro. On the bottom of the sheet,
where I had the sheets-numbers, I always got the correct sheet numbers.
Now, I use ooO 3.0, and I suddenly have problems.
In our example I declare the sheets-numbers Tabelle11 and Tabelle31. As soon
as I call the spreedsheet I get the sheet-number Tabelle1, which apparently
is being generated by ooO. I see all the cells which I had typed when I
created the table. After I call the macro, the routine goes to the point
where I want to call Tabelle31. At that position I get the
outofboundexception. The spreadsheet does not show either Tabelle11 or
Tabelle31. The system acts as if I would have not called either Tabelle11 or
Tabelle31. Here is the entire code.
Option Explicit
Sub Main
Dim Desktop As Object
Dim Platzhalter()
Dim Url As String
Dim oTabellenDokument As Object
Dim oTabellenListe As Object
Dim Tabelle11 As Object
Dim Tabelle31 As Object
Dim EndSpalte As Integer
Dim EndZeile As Integer
Dim I As Integer
Dim Cursor As Object
Dim ZellenBereich As New com.sun.star.table.CellRangeAddress
Dim ZellenAdresse As New com.sun.star.table.CellAddress
ZellenBereich.Sheet = 0
ZellenBereich.StartColumn = 0
ZellenBereich.EndColumn = 30
ZellenBereich.StartRow = 0
ZellenBereich.EndRow = 300
ZellenAdresse.Sheet = 0
ZellenAdresse.Column = 0
ZellenAdresse.Row = 0
EndSpalte = ZellenBereich.EndColumn
EndZeile = ZellenBereich.EndRow
oTabellenDokument = ThisComponent
rem oTabellenDokument.LockControllers
Desktop = CreateUnoService("com.sun.star.frame.Desktop")
Url = "file:///a:/mist.ods"
oTabellenDokument = Desktop.loadComponentFromURL(Url, "_blank", 0,
Platzhalter())
oTabellenListe = oTabellenDokument.getSheets()
Tabelle11 = oTabellenListe.GetByIndex(0)
Tabelle31 = oTabellenListe.GetByIndex(1)
End Sub
You question, I I reference the correct document. I run the macro with
break-points.
The only point where I am nor sure of are the LockControllers and
CurrentController statements. I declared them both, for the cell-area
("Zellenbereich") and the entire document.
I also tried getByName instead of getByIndex. I got the same
outofboundexception..
I really appreciate your help.
Regards,
Rudi
----- Original Message -----
From: "Andrew Douglas Pitonyak" <[EMAIL PROTECTED]>
To: <dev@api.openoffice.org>
Sent: Sunday, December 07, 2008 7:36 PM
Subject: Re: [api-dev] Calc with two tables
Rudolf Huber wrote:
Hallo Andrew,
thanks for the prompt answer. Instead of
Tabelle31 = oTabellenListe.getByIndex(1)
I coded
Print oTabellenListe.getCount()
Print
oTabellenDokument.getSheets().getCount()
Tabelle31 =
oTabellenDokument.getSheets().getByIndex(1)
the macro handled both printing statements.
And what did they print? My guess is that they both printed the valued 1.
Is this correct? Is this the value that you expected?
The statement for Tabelle31 is not executed anymore; the system throws an
indexoutofboundexception. The sheet itself does not show on the buttom
the sheet-id-numbers Tabelle11 und Tabelle31, but Tabelle1. One line
below, the sheet shows Tabelle1/1. Maybe the code for ThisComponent and
lockcontrollers is incorrect?
I am not sure what you are saying. Are you implying that you are not
referencing the correct document?
Regards,
Rudi
----- Original Message ----- From: "Andrew Douglas Pitonyak"
<[EMAIL PROTECTED]>
To: <dev@api.openoffice.org>
Sent: Thursday, December 04, 2008 2:25 PM
Subject: Re: [api-dev] Calc with two tables
Rudolf Huber wrote:
Hallo,
the following sequence leads to an "indexoutofboundexception". In the
beginning I have the opening statements:
Dim Desktop As Object
Dim Platzhalter()
Dim Url As String
Dim oTabellenDokument As Object Rem the
entire Document
Dim oTabellenListe As Object Rem
Collection of sheets
Dim Tabelle11 As Object Rem
sheet
Dim Tabelle31 As Object Rem
sheet
thereafter a little further down: :
oTabellenDokument = ThisComponent
oTabellenDokument.lockcontrollers
EndSpalte = ZellenBereich.EndColumn
EndZeile = ZellenBereich.EndRow
Desktop = CreateUnoService("com.sun.star.frame.Desktop")
Url = "file:///a:/test.ods"
oTabellenDokument = Desktop.loadComponentFromURL(Url, "_blank", 0,
Platzhalter())
oTabellenListe = oTabellenDokument.getSheets()
Tabelle11 = oTabellenListe.getByIndex(0)
again further down, the table Tabelle31 throughs the index-error:
Tabelle31 = oTabellenListe.getByIndex(1)
Up version 2.4 I had no problem with a structure like this. Now, I have
version ooO 3. The table-collection oTabellenListe should allow
various sheets, however, macro stops after one table. In the sheet
itself Tabelle1 in the beginning; after the url the second sheet shows
Tabelle1/1. Neither Tabelle11 nor the Tabelle31 - which I coded -
appear on the sheet. I do not know, why the macro ignores the
definitions for the tables Tabelle11 und Tabelle31.
You said that more than one sheet exists in the document. What happens
if you do this?
Print oTabellenListe.getCount()
Print oTabellenDokument.getSheets().getCount()
Tabelle31 = oTabellenDokument.getSheets().getByIndex(1)
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]