Pfad für Auswahldialog
26.06.2007 15:11:00
Andreas
Ein kleines Problem für einen Profi, aber ein großes für einen Laien.
Ich habe diesen code aus der Recherche (is von Nepumuk):
Option Explicit
Private Type InfoT
hwnd As Long
Root As Long
DisplayName As Long
Title As Long
Flags As Long
FName As Long
lParam As Long
Image As Long
End Type
Private Declare
Function SHBrowseForFolder Lib "shell32" (lpbi As InfoT) As Long
Private Declare
Function CoTaskMemFree Lib "ole32" (ByVal hMem As Long) As Long
Private Declare
Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpStr1 As String, ByVal lpStr2 As _
String) As Long
Private Declare
Function SHGetPathFromIDList Lib "shell32" (ByVal pList As Long, ByVal lpBuffer As String) As _
_
Long
Private Declare
Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassname As String, ByVal _
lpWindowName As String) As Long
Sub GetAOrdner(WDir As String)
Dim xl As InfoT, IDList As Long, RVal As Long, FolderName As String
With xl
.hwnd = FindWindow("xlmain", vbNullString)
.Title = lstrcat("Bitte wählen Sie ein Verzeichnis", "")
.Flags = 1
End With
IDList = SHBrowseForFolder(xl)
If IDList 0 Then
FolderName = Space(256)
RVal = SHGetPathFromIDList(IDList, FolderName)
CoTaskMemFree (IDList)
FolderName = Trim(FolderName)
FolderName = Left(FolderName, Len(FolderName) - 1)
End If
WDir = FolderName
End Sub
Der code lässt mich über einen Dialog ein Verzeichnis auswählen.
Wie kann ich dem code einen Pfad für die Auswahl vorgeben?
Hoffe auf Hilfe
Andreas