Dim variable assigning

why won’t is sub except a single letter as a input, It returns zero
sub nnn

oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()
ThisSheet = oActiveSheet

dim b as variant
for a = 1 to 7
b = ThisSheet.getCellByPosition(a + 23 , 35).getValue
ThisSheet.getCellByPosition(a + 23 , 33).setValue(b)
next

End Sub
Tks for any help in advance

Hallo

sub nnn
 ThisSheet = ThisComponent.CurrentController.ActiveSheet
 data = ThisSheet.getCellRangeByPosition(24, 35, 31, 35).DataArray
 ThisSheet.getCellRangeByPosition(24, 33, 31, 33).DataArray = data
End Sub
1 Like

The GetValue method appears to specifically request numerical value. Can’t see a method to fetch arbitrary type (variant) data, but I didn’t put much effort into searching, so it may well exist. More likely, only strict type methods exist and you need to detect data type before applying the relevant get…/set… operations.

edit: Simple assignment should work on “variant” where the “strict type” class methods don’t. @karolus has got you covered. I’m stupid :wink:

Reference:

https://wiki.openoffice.org/wiki/Documentation/OOo3_User_Guides/Calc_Guide/Accessing_cells_directly