Object variable not set ?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Object variable not set ?

Post by BubikolRamios »

MSG box pops up wizh no message / OK
--> object variable not set

Must be something obvious - I don't see it.

Code: Select all


Option Explicit
sub Main
rem ----------------------------------------------------------------------

Dim oDoc As Object
   Dim oText As Object
   Dim oVCurs As Object
   Dim oTCurs As Object
   Dim ser As String
   Dim i As Integer
       
   oDoc = ThisComponent
   oText =oDoc.getText()
   Dim matrix as Variant
   matrix = Array(_
            Array("Bl.", "Blatt"),_
            Array("Blü.","Blüte"),_
            Array("-fg.", "-förmig"),_
            Array("Fr.", "Frucht"),_
            Array("Frkn.", "Fruchtknoten"),_
            Array("Gr.", "Griffel"),_
            Array("K.", "Kelch"),_
            Array("Kbl.", "Kelchblatt"),_
            Array("Kr.", "Krone"),_
            Array("Krbl.", "Kronblatt"),_
            Array("mehrj.", "mehrjährig"),_
            Array("Pfl.", "Pflanze"),_
            Array("St.", "Stängel, Stiel"),_
            Array("Staubbl.", "Staubblatt"),_
            Array("u.", "und"))
           
    i = 0

For i= Lbound(matrix,1) To Ubound(matrix,1)
  
  
    MsgBox (matrix(i, 0))
  Next i

OPen office 4.1.5/ win 7
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Object variable not set ?

Post by FJCC »

Try using

Code: Select all

MsgBox (matrix(i)( 0))
As I understand it, you have an array of arrays, so ask of the 0th component of the ith array.
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
Lupp
Volunteer
Posts: 3542
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Object variable not set ?

Post by Lupp »

oText is unused.
The closing End Sub is missing.
Row i = 0 unneeded.

The variant variable matrix is dimensioned by the constant assignment as an array of arrays, not as a matrix with two indexing dimensions.
To get access to the first element of any array being an entry on the first level (call it "rows"), you need to write matrix(i)(0) therefore.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
BubikolRamios
Posts: 91
Joined: Sat Jan 04, 2014 1:28 pm

Re: Object variable not set ?

Post by BubikolRamios »

Thanks.

Code: Select all

i =0
is residuum of my delphi troubles solving (-:
OPen office 4.1.5/ win 7
Post Reply