I’m trying to insert a new row, copy formats from the row bellow, update formula in one column, and copy some cells from row bellow. If I try to call ScriptForge library, I don’t seem to have any methods to do so apart from CopyToCell or CopyToRange, and this only works if I run macro from withing the spreadsheet, now within window with macros.
1.) Is there a way to select particular sheet with ScriptForge lib?
I took basic example code from help and it looks like this:
Sub Main
GlobalScope.BasicLibraries.LoadLibrary("ScriptForge")
Dim sDoc as Object
sDoc = CreateScriptService("Calc")
rem Following doesn't work
' sDoc = CreateScriptService("SFDocuments.Calc", "MyStat.ods")
sDoc.CopyToCell("Sheet1.A4:P4","Sheet1.A3")
End Sub
2.) So to do remaining operations I used ThisComponent. Is there a way to do it elegantly with calling one lib only and less operations? (just capy range and clear unwanted values)
Sub Main
Dim cDoc as Object
Dim cSheet as Object
cDoc = ThisComponent
cSheet = cDoc.Sheets.GetByName("Sheet1")
cSheet.Rows.insertByIndex(2, 1)
cSheet.Rows(2).OptimalHeight = True
cSheet.getCellRangeByPosition(0,2,0,4).FillAuto(2, 1)
For i = 1 To 9
cSheet.getCellByPosition(i, 2).CellStyle = cSheet.getCellByPosition(i, 3).CellStyle
Next
cSheet.getCellByPosition(3, 2).Value = cSheet.getCellByPosition(3, 3).Value
End Sub
My Version
Version: 7.2.5.2.0+
Build ID: 20(Build:2)
CPU threads: 12; OS: Linux 5.15; UI render: default; VCL: gtk3
Locale: en-GB (en_US.UTF-8); UI: en-US
Calc: threaded
Thanks