Zuerst noch: frohe Ostern.
Meine Frage: wie kann ich per VBA den Explorer aufrufen, um ein bestimmtes Verzeichnis anzuzeigen. Gleichzeitig sollte Excel auf die Beendigung des Explorers warten. Ist das möglich?
Gruß Joschi
Code:
Private Declare PtrSafe Function FindWindowA Lib "user32" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As LongPtr
Private Declare PtrSafe Function ShellExecuteA Lib "Shell32.dll" ( _
ByVal hwnd As LongPtr, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As LongPtr
Sub Explorer()
Dim sLink As String, sText As String
Const SW_RESTORE = 9
sLink = "C:\Users\volti\Desktop\MyTools" '<<< anpassen >>>
sText = Mid$(sLink, InStrRev(sLink, "\") + 1)
If ShellExecute(0&, "Explore", sLink, 0, 0, SW_RESTORE) <> 0 Then
Do
If FindWindowA("CabinetWClass", sText) <> 0 Then Exit Do
DoEvents
Loop
Do
If FindWindowA("CabinetWClass", sText) = 0 Then Exit Do
DoEvents
Loop
End If
End Sub