CreateUnoService Funció

Instantiates a Uno service with the ProcessServiceManager.


     CreateUnoService(serviceName As String) As Object

For a list of available services, visit the com::sun::star Module reference page.


The example below creates the function FileExists that uses the service to test if a given path is an existing file.

    Function FileExists(sPath as String) As Boolean
        Dim svcSFA As Object
        Set svcSFA = CreateUnoService("")
        Dim bExists As Boolean : bExists = svcSFA.exists(sPath)
        Dim bIsFolder As Boolean : bIsFolder = svcSFA.IsFolder(sPath)
        FileExists = bExists And Not bIsFolder
    End Function ' FileExists

UNO services have an extensive online documentation in the website. Visit the SimpleFileAccess Service reference page to learn more about the methods provided by the service used in the example above.


El codi següent utilitza el servei per a mostrar un diàleg d'obertura de fitxers:

Sub Main
    fName = FileOpenDialog ("Seleccioneu un fitxer")
    Print "fitxer triat: "+fName
End Sub
Function FileOpenDialog(title As String) As String
    res =
    filepicker = CreateUnoService("")
    filepicker.Title = title
    If res.OK = filepicker.execute() Then 
        files = filepicker.getSelectedFiles()
End Function ' Main

Ens cal la vostra ajuda!