ich möchte einen Ordner öffnen und ihn dann direkt on top anzeigen lassen. Hab sowas wie opendir nicht gefunden. Wer kann mir helfen?
Danke
ich möchte einen Ordner öffnen und ihn dann direkt on top anzeigen lassen. Hab sowas wie opendir nicht gefunden. Wer kann mir helfen?
Danke
'32-bit API-Deklarationen Declare Function SHBrowseForFolder Lib "shell32.dll" _ Function getdirectory(Optional msg) As String ' Ausgangsordner = Desktop ' Dialogtitel ' Rückgabe des Unterverzeichnisses ' Dialog anzeigen ' Ergebnis gliedernPublic Type BROWSEINFO
Code eingefügt mit Syntaxhighlighter 1.14
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
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Sub DirAuswahl()
Dim msg As String
msg = "Wählen Sie bitte einen Ordner aus:"
MsgBox getdirectory(msg)
End Sub
Dim bInfo As BROWSEINFO
Dim Path As String
Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(msg) Then
bInfo.lpszTitle = "Wählen Sie bitte einen Ordner aus."
Else
bInfo.lpszTitle = msg
End If
bInfo.ulFlags = &H1
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
Viele Grüße
Bernd
MVP für Microsoft Excel
Excel-Tipps, VBA in 21 Tagen mit Leseprobe(PDF) unter: http://held-office.de
In der Recherche über Suche und Begriff Explorer finde ich u.a.
Sub ExplorerFensterÖffnen()
VerzName = "C:\USERS\Daten"
On Error Resume Next
dd = Shell("C:\WINNT\explorer.exe /e,/n,," & VerzName, 4)
On Error GoTo 0
End Sub