I wrote this small macro (see below), where am trying to read data form a data range A defined with the help of getCellRangeByName.
The macro sets the values in the cell $A$1 to 1 and in the cell $B$2 to 2 and define the range A with the address $A$1:$B$2.
I thought that I coud that way access the values of the data in the range by using for instance A(1,1).value, A(2,2).Value.
But in fact A(2,2).value has always the same value as A(1,1).Value, ie. A(2,2).value=A(1,1).Value=1.
What would be the right way to adress the cells in range A in order to read the correct values?
Thank you for your advice.
Bruno
Code: Select all
Sub test()
Dim A As Variant
Dim Doc As Object
Dim oSheet As Object
Dim Cell As Object
Doc = ThisComponent
oSheet = ThisComponent.CurrentController.ActiveSheet
Cell = oSheet.getCellByPosition(0,0)
Cell.Value=1
Cell = oSheet.getCellByPosition(1,1)
Cell.Value = 2
A = oSheet.getCellRangeByName(Cells(1, 1).Address, Cells(2, 2).Address)
print A(1,1).Value
print A(2,2).Value
End Sub