The code I copied a long time ago from the OzGrid site but I still haven't been able to figure out how to set the folder to start in using the UDF
Function GetFolder(strPath As String, Optional sTitle As String) As String Dim fldr As FileDialog Dim sItem As String isOk = FolderExists(strPath) If Len(Trim(strPath)) = 0 Or isOk = False Then strPath = "" End If Set fldr = Application.FileDialog(msoFileDialogFolderPicker) With fldr .InitialFileName = strPath .Title = "Select " & IIf(Len(Trim(sTitle)) > 0, sTitle, "a Folder:") .AllowMultiSelect = False .ButtonName = "Select folder" If .Show <> -1 Then GoTo NextCode sItem = .SelectedItems(1) End With NextCode: GetFolder = sItem Set fldr = Nothing End Function
I pass the parameter (which is valid) as strPath (with and without the final backslash) and it always starts in a previously selected folder.
Even if the value for InitialFileName is filled or not
the value in strPath can either be a UNC share or a local folder.
Can somebody point me in the right direction?
I cannot use ChDir because it will not work, especially if it points to a network share (UNC path)
Hope somebody has an idea.