Code: Select all
Option Explicit
Sub Main
SetDataM
'SetDataV
End Sub
Sub SetDataM
Dim i As Integer, j As Integer
Dim Doc As Object
Dim Sheet As Object, Sheets As Object
Dim Range as Object
Dim DA (4,1) As Integer 'r c
Doc = ThisComponent
Sheets = Doc.Sheets
Sheet = Sheets.getByName("Test")
Range = Sheet.getCellRangeByName("A1:B5")
Randomize()
For i = 0 to 4 'r
For j = 0 to 1 'c
DA (i,j) = Int((99 * Rnd))
Next j
Next i
MRI Range
MRI DA
Range.setDataArray(DA())
End Sub
Sub SetDataV
Dim i As Integer, j As Integer
Dim Doc As Object
Dim Sheet As Object, Sheets As Object
Dim Range as Object
Dim DA (4) As Integer 'r
Doc = ThisComponent
Sheets = Doc.Sheets
Sheet = Sheets.getByName("Test")
Range = Sheet.getCellRangeByName("A1:A5")
Randomize()
For i = 0 to 4 'r
DA (i) = Int((99 * Rnd))
Next i
MRI Range
MRI DA
Range.setDataArray(DA())
End Sub
Is the object variable Range (as opposed to DA)?
Both Range and DA appear to be ok in MRI. I also note that setData Array is an available method of the Range object.
Also when I put them both on watch and with breakpoints at the "Range.setDataArray(DA())" line the items also appear to be ok in the Watch window.
Is the problem simply that in AOO an array means a 2 dimensional array and vectors are not treated as a 1 dimensional array and therefore setDataArray simply doesn't work on them?