I’m trying some BASIC code for a Macro in LibreOffice-Calc to copy 16 cells from a spreadsheet, then paste them transposed to a new location on the same datasheet
I worked up an indexer to pick the cells starting at 3:18, then 23:38, then 43:58, etc.
It goes through fine on the first loop, but on the second loop it errs out.
BASIC runtime error.
An exception occurred
Type: com.sun.star.lang.IllegalArgumentException
Message: sequence element is not assignable by given value! at C:/cygwin64/home/buildslave/source/libo-core/stoc/source/corereflection/crarray.cxx:136.
Here’s the code:
REM ***** BASIC *****
sub Main
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
for i = 1 to 10
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
rem need a sequence that goes 3, 23, 43, 63, etc
rowfrom = 20*(i-1)+3
rowto = rowfrom+15
rem args1(0).Value = "$A$3:$A$18"
rowfromstr = mid(str(rowfrom),2,20)
rowtostr = mid(str(rowto),2,20)
buildstring = "$A$" & rowfromstr & ":$A$" & rowtostr
args1(0).Value = buildstring
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(0) as new com.sun.star.beans.PropertyValue
args3(0).Name = "ToPoint"
args3(0).Value = "$B$1"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args3())
dispatcher.executeDispatch(document, ".uno:PasteTransposed", "", 0, Array())
next i
end sub
The string looks fine going in to the second variable assignment, but when it gets to the dispatcher, it errs out.