When I try to open a calc ods file with the hidden as true, loadComponentFromURL returns “Nothing”.
I need to read some cells values without really openning Libreoffice Calc.
Does anyone knows how to make this to work?
Thanks
Sub ReadODS()
Dim objDocument
Set objServiceManager = WScript.CreateObject("com.sun.star.ServiceManager")
Set StarDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
Dim args0(0)
Set args0(0) = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
Set args0(0) = MakePropertyValue("Hidden", true)
cCSVURL = "file:///C:\validar\25-05-2022.ods"
Set objDocument = StarDesktop.loadComponentFromURL(cCSVURL, "_blank", 0, args0 )
set oSheet = objDocument.getSheets().getByName( "Inspeção" )
Set objCell = oSheet.getCellByPosition( 1, 2 )
msgbox objCell
Set objServiceManager = Nothing
Set StarDesktop = Nothing
Set oEnum = Nothing
objDocument.Close (True)
Set objDocument = Nothing
Set oSheet = Nothing
Set oCell = Nothing
End Sub
Function MakePropertyValue(cName, uValue)
Dim oStruct
Set oServiceManager = WScript.CreateObject("com.sun.star.ServiceManager")
Set oStruct = oServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oStruct.Name = cName
oStruct.Value = uValue
Set MakePropertyValue = oStruct
End Function