AW: Mit diesen beiden...
Theo
Vielen Dank schonmal,
das war ursprünglich mal mein Startpunkt. Leider zeigt dieser Dialog keine Inhalte der Ordner an, so dass der Ordner leer zu sein scheint.
Deshalb hatte ich seinerzeit erst mal auf den folgenden Dialog migriert, bei dem ich aber dafür keinen StartFolder vorgeben kann.
Function FolderDialogueLegacy(Msg As String) As String
Dim bInfo As BROWSEINFO
Dim path As String
Dim TempStr As String
Dim r As Long, x As Long, pos As Integer
'---------------------------
' Root folder = Desktop
bInfo.pidlRoot = 0&
'---------------------------
' Title in the dialog
If IsMissing(Msg) Then
bInfo.lpszTitle = "Select a folder."
Else
bInfo.lpszTitle = Msg
End If
'---------------------------
' Type of directory to return
bInfo.ulFlags = 16385 '&H1
'---------------------------
' Display the dialog
x = SHBrowseForFolder(bInfo)
'---------------------------
' Parse the result
path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal path)
If r Then
pos = InStr(path, Chr$(0))
TempStr = Left(path, pos - 1)
'----------------------------------------------------------------------------------------------
'--- Find the position of the last backslash
'----------------------------------------------------------------------------------------------
pos = InStrRev(TempStr, "\")
'----------------------------------------------------------------------------------------------
'--- is there a "dot" after the last backslash? if yes we need to remove the filename from the string
'----------------------------------------------------------------------------------------------
If InStr(pos, TempStr, ".") > 0 Then
TempStr = Left(TempStr, pos)
MsgBox prompt:="You have selected a file rather than a folder!" & Chr(10) _
& "We will use the folder of the selected file: " & Chr(10) _
& Chr(39) & TempStr & Chr(39), Buttons:=vbOKOnly, Title:="File Folder used"
End If
FolderDialogueLegacy = TempStr
Else
FolderDialogueLegacy = Msg
End If
End Function