I use the following code to select a file in a Windows Explorer window:
Set objShellAPP = CreateObject("Shell.Application")
objShellAPP.Open(WScript.Arguments(0))
WScript.Sleep(300)
On Error Resume Next ' For new unsaved files.
With objShellAPP.Windows(objShellAPP.Windows.Count - 1).document
.SelectItem .Folder.Items.Item(WScript.Arguments(1)), 29
End With
Set objShellAPP = Nothing
objShellAPP.Open()
opens the folder in the last active window;
objShellAPP.Windows.Count - 1
is not necessarily that window.
How can I get the last active window for the With objShellAPP.Windows(---).document
line?
Thank you.
See:
Open and Select a file in an existing Explorer window
No comments:
Post a Comment