Fonction CreateUnoService

Crée une instance d'un service Uno à l'aide de ProcessServiceManager.

Syntaxe :

oService = CreateUnoService (nom de service Uno)

Pour une liste des services disponibles, aller à : https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star.html

Exemple :

Calling Calc functions in Basic:


    Function MyVlook(item, InRange As Object, FromCol As Integer)
        Dim oService As Object
        oService = createUnoService("com.sun.star.sheet.FunctionAccess")
        REM Always use the function English name
        MyVlook = oService.callFunction("VLOOKUP",Array(item, InRange, FromCol, True))
    End Function

Exemple :

oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" )

Le code suivant utilise un service pour ouvrir la boîte de dialogue d'ouverture de fichier :


Sub Main
    fName = FileOpenDialog ("Veuillez sélectionner un fichier")
    Print "fichier sélectionné : "+Nomf
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