Grüezi Zondan
gibt es eine Möglichkeit das aus vielen Programmen bekannte
„Datei öffnen“ (bzw. eigentlich bräuchte ich „Pfad öffnen“)
Fenster mit einem VB Befehl aufzurufen und den Pfad
zurückzubekommen?
Ich habe hier ein paar Code-Zeilen, die mit Excel problemlos funktionieren; vielleicht reicht das schon oder Du kannst sie anpassen:
Option Explicit
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare Function SHGetPathFromIDList Lib "shell32.dll" \_
Alias "SHGetPathFromIDListA" \_
(ByVal pidl As Long, ByVal \_
pszPath As String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" \_
Alias "SHBrowseForFolderA" \_
(lpBrowseInfo As BROWSEINFO) As Long
'Ruft das Dialogfeld zur Ordnerauswahl auf
Function GetDirectory(Msg) As String
Dim bInfo As BROWSEINFO
Dim Path As String
Dim R As Long, x As Long, pos As Integer
With bInfo
.pidlRoot = 0&
.lpszTitle = Msg
.ulFlags = &H1
End With
x = SHBrowseForFolder(bInfo)
Path = Space$(512)
R = SHGetPathFromIDList(ByVal x, ByVal Path)
If R Then
pos = InStr(Path, Chr$(0))
GetDirectory = Left(Path, pos - 1)
Else
GetDirectory = ""
End If
End Function
Public Sub open\_Path()
Dim strPath As String
strPath = GetDirectory("Bitte einen Ordner wählen") 'Ersatz: ... = C:\Eigene Dateien"
MsgBox strPath
End Sub
–
Mit freundlichen Grüssen
Thomas Ramel