Hello,
I started using LibreOffice for my Calc document with macros written in BASIC. In OpenOffice, this works, but in LibreOffice, this part of the code does not function when I attempt to use it for the first time after opening the document (without any warnings; the rest of the code runs without problems). However, after manually clicking with the mouse in the spreadsheet area where the code is supposed to perform an action (refer to the code), this part of the code works. After this “intervention,” when I run the code again, a window shows up with the following message: “You are pasting data into cells that already contain data. Do you really want to overwrite the existing data?” (Very strange, because the code in the previous step deleted all contents and formatting of the cell range.) After confirming this, the code runs successfully. The next time the code runs without any problems or system warnings. The code simply copies and pastes a certain range of cells. Here is the code:
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$FR$2:$GD$29"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
dispatcher.executeDispatch(document, ".uno:Copy", "", 0, Array())
dim args6(0) as new com.sun.star.beans.PropertyValue
args6(0).Name = "ToPoint"
args6(0).Value = "R" & oFoundRow+2
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args6())
dispatcher.executeDispatch(document, ".uno:Paste", "", 0, Array())