Funzione CreateUnoService
Crea un'istanza di un servizio Uno con il ProcessServiceManager.
oServizio = CreateUnoService( nome servizio Uno )
Per un elenco dei servizi disponibili, consultate: https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star.html
Richiamare funzioni Calc in Basic:
Function MyVlook(item, InRange As Object, FromCol As Integer)
Dim oService As Object
oService = createUnoService("com.sun.star.sheet.FunctionAccess")
REM Usare sempre il nome inglese della funzione
MyVlook = oService.callFunction("VLOOKUP",Array(item, InRange, FromCol, True))
End Function
oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" )
Il codice seguente utilizza un servizio per aprire una finestra di apertura file:
Sub Main
fName = FileOpenDialog ("Selezionate un file")
Print "file scelto: "+fName
End Sub
Function FileOpenDialog(title As String) As String
filepicker = createUnoService("com.sun.star.ui.dialogs.FilePicker")
filepicker.Title = title
filepicker.execute()
files = filepicker.getFiles()
FileOpenDialog=files(0)
End Function