You may have to create your oSM and oDesk.
I can neither tell from knowledge anything about VB nor can I test.
But the functional part of the code looking as if it is BASIC with some LibO/AOO API-calls looks somehow bureaucratic to me.
I simplified it to
Code: Select all
Sub Test()
oDoc = StarDesktop.LoadComponentFromURL(ConvertToURL("C:\Users\Wolfgang\Documents\3Arbeit\test\testsheet.ods"), "_blank", 0, Array())
oSheet = oDoc.Sheets(0)
Dim oCRAddr As New com.sun.star.table.CellRangeAddress
myCellInsertMode = 1
oCRAddr.Sheet = 0
oCRAddr.StartColumn = 1
oCRAddr.StartRow = 1
oCRAddr.EndColumn = 2
oCRAddr.EndRow = 2
oSheet.insertCells(oCRAddr, myCellInsertMode)
End Sub
and this worked as expected.
Dim oCRAddr As Object : This shouldn't cause an error, but, as Villeroy already told, a CellRangeAddress isn't of an object type, but of a specific UnoStruct type.
oCRAddr = CreateUnoStruct("com.sun.star.table.CellRangeAddress") also works.
URL = "file:///D:/Open%20Office/test%201.csv" : What are the spaces good for?
If you need to run the code from AOO BASIC because the VB bridge is inapt, you may place the code into a module (in my case
Tests) of your AOO Standartd library and activate it like an OS command:
Code: Select all
"C:\Program Files\OpenOffice\program\soffice.exe" macro:///Standard.Tests.myTestMacro
(Adapt your soffice.exe path according to your system.)
I tested this with LibO V5.4.4 and it worked flawlessly.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München