Page 1 of 1
[Solved] Retrieving OO version (OO + VB6)
Posted: Tue Aug 21, 2012 4:21 pm
by Tenebroleso
Hi all,
is it possible to retrieve the version of OO installed using API? Which API can I use?
Thank you!
Re: Retrieving OO version (OO + VB6)
Posted: Tue Aug 21, 2012 4:36 pm
by Villeroy
Code: Select all
Function getOOoVersion() As String
getOOoVersion = getOOoSetupValue("/org.openoffice.Setup/Product","ooSetupVersion")
end Function
Function getOOoSetupNode(sNodePath$)
Dim aConfigProvider, oNode, args(0) As new com.sun.star.beans.PropertyValue
aConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
args(0).Name = "nodepath"
args(0).Value = sNodePath
getOOoSetupNode = aConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", args())
End Function
Function getOOoSetupValue(sNodePath$,sProperty$)
Dim oNode
oNode = getOOoSetupNode(sNodePath)
getOOoSetupValue = oNode.getbyname(sProperty)
End Function
Re: Retrieving OO version (OO + VB6)
Posted: Tue Aug 21, 2012 5:00 pm
by Tenebroleso
I have found this code too and have tried to convert to VB6 but seems not to work.
This is why I'm here asking VB6 code.

Re: Retrieving OO version (OO + VB6)
Posted: Tue Aug 21, 2012 5:08 pm
by RoryOF
OpenOffice does not use VB6 code. Mastering the OpenOffice API is much more complex
Re: Retrieving OO version (OO + VB6)
Posted: Tue Aug 21, 2012 5:22 pm
by Villeroy
Of course you can do the same in VB6 if you know how to create the UNO service to read configuration data. If you do not know how to do that, then you can not do much with UNO without a constant flow of other people's code snippets.
Re: Retrieving OO version (OO + VB6)
Posted: Tue Aug 21, 2012 5:26 pm
by Tenebroleso
Solved.
Code: Select all
Public Function VersionOO(oServiceManagerLav As Object, oDesktopLav As Object) As String
Dim oConfigProvider As Object
Dim oSettings As Object
Dim oArguments(0) As Object
Set oConfigProvider = oServiceManagerLav.createInstance("com.sun.star.configuration.ConfigurationProvider")
Set oArguments(0) = oServiceManagerLav.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
oArguments(0).Name = "nodepath"
oArguments(0).Value = "/org.openoffice.Setup/Product"
Set oSettings = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", oArguments())
VersionOO = oSettings.getByName("ooSetupVersion")
End Function