I've found various bits and pices around the site and the internet but I'm now stuck.
I'm using Vb5 and OO 4.1.4 on a WIndows 10 PC.
Any ideas please?
Regards
Peter
Code: Select all
Private Sub Form_Load()
Dim oSM As Object 'Root object for accessing OpenOffice from VB
Dim oDesk As Object 'First objects from the API
Dim oDoc As Object 'First objects from the API
Dim OpenParam(1) As Object 'Parameters to open the doc
Dim oPropertyValue As Object
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
Set oPropertyValue = oSM.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
'Open existing doc
oDoc = oDesk.loadComponentFromURL("file:///D:/OpenOffice/test1.csv", "_blank", 0, OpenParam)
'calc loads Ok But I can't seem to do anything with the spreadsheet
'...various things that I've tried so far, all give the same result:
'...error 91 Object variable or With block variable not set
Dim oSheet As Object
Dim oRange As Object
oSheet = oDoc.Sheets(0)
Set oSheet = oDoc.Sheets(0)
Set oSheet = oDoc.Sheets.getByName("Sheet1")
Set oRange = oSheet.getCellRangeByName("A1:B2")
Call oSheet.getCellRangeByName("A2").setString("test")
Set oSheet = oDoc.Sheets.getByName("Sheet1")
Set oSheet = oDoc.getSheets().getByIndex(0)
Set oRange = oSheet.getCellRangeByName("A1:B12")
End sub