I have a macro that I created a couple years ago. Time (and a brain surgery) has prevented my remembering what is supposed to be happening, here. (It’s a good object lesson on why comments in code are a good idea.) I’d say there’s a good chance I copied most of this from somewhere else. (My most common resource when I created this was probably Andrew P’s references.
The line that begins oRegistryKeyContent = oConfigProvider keeps throwing an error “cannot find /org.openoffice.Office.Common/Path/Info.” I did manage to find this bug thread, where Comment 52 suggests that the solution is to make the path something on the local machine. That’s not really an option for our workflow.
Function SelectFile(FilterNames() as string) As String
dim oFileDialog as object
Dim iAccept as integer
Dim sPath
dim sInitPath as string
Dim sRefControlName
dim oUCB as object 'Simple File Access Uno Service
With globalScope.basicLibraries
If not .isLibraryLoaded("Tools") Then
.loadLibrary("Tools")
End If
End with
dim aNodePath(0) as new com.sun.star.beans.PropertyValue
dim oConfigProvider as object
With globalScope.basicLibraries
If not .isLibraryLoaded("Tools") Then
.loadLibrary("Tools")
End If
' If .isLibraryLoaded("Tools") Then
' msgbox "Tools Loaded"
' End If
End with
oUCB = createUnoService("com.sun.star.ucb.SimpleFileAccess")
oFileDialog = createUnoService("com.sun.star.ui.dialogs.FilePicker")
' sInitPath = convertToURL("O:\ISO-IEC-17025\Server\QMS Documents\Working")
' sinitPath = oFileDialog.getDisplayDirectory
' msgbox sinitPath
sInitPath = convertToURL("L:\QMS Documents\Working")
oConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
AddFiltersToDialog(FilterNames(), oFileDialog)
If oUCB.Exists(sInitPath) Then
oFileDialog.setDisplayDirectory(sInitPath)
With aNodePath(0)
.Name = "nodepath"
.Value = "/org.openoffice.Office.Common/Path/Info"
End With
oRegistryKeyContent = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath())
With oRegistryKeyContent
.WorkPathChanged = true
.commitChanges
End With
Else
msgBox "Error! Built-in path for documents is incorrect"
Exit Function
End If
iAccept = oFileDialog.execute()
If iAccept = 1 Then
sPath = oFileDialog.Files(0)
SelectFile = sPath
End If
oFileDialog.Dispose()
End Function