No código a seguir, a primeira janela do Windows Explorer é ativada e, em seguida, uma pasta é aberta lá (eu uso QTTabbar ).
Set objShellApp = CreateObject("Shell.Application")
Dim winFolder
For Each wFolder In objShellApp.Windows
On Error Resume Next
isFolder = wFolder.document.folder ' An IE window does not support ".document.folder". We get the first Windows Explorer window.
If Err = 0 Then
wFolder.Visible = True
Set winFolder = wFolder
Exit For
End If
Next
objShellApp.Open(WScript.Arguments(0))
WScript.Sleep(300)
If NOT WScript.Arguments(1) = "" Then
If winFolder = Empty Then
Set winFolder = objShellApp.Windows(objShellApp.Windows.Count - 1) ' A Windows Explorer window opened with objShellApp.Open(WScript.Arguments(0)) is the last one in the index (Count - 1).
End If
On Error Resume Next ' For new unsaved files.
With winFolder.document
.SelectItem .Folder.Items.Item(WScript.Arguments(1)), 29
End With
End If
Set winFolder = Nothing
Set objShellApp = Nothing
Quanto a uma maneira melhor de distinguir entre o Windows Explorer e o Internet Explorer:
VBS: Distinguis entre o Windows Explorer e o Internet Explorer