Other Software > Developer's Corner
VBS: Select one file in a folder
(1/1)
Yaron:
Hello,
The following code selects arg1 in a Windows Explorer folder:
--- ---Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run("""" & WScript.Arguments(0) & """")
WScript.Sleep 400
' objShell.SendKeys("^a{F5}") ' Deslect All.
Set objShellAPP = CreateObject("Shell.Application")
On Error Resume Next ' For new unsaved files.
With objShellAPP.Windows(objShellAPP.Windows.Count - 1).document
.SelectItem .Folder.Items.Item(WScript.Arguments(1)), 17
End With
Set objShell = Nothing
Set objShellAPP = Nothing
If fileA is already selected in the folder and fileB is passed as arg1, both files are selected.
How can I have fileA deselected and only fileB selected?
The commented line
--- ---objShell.SendKeys("^a{F5}") is a workaround, but there must be a better way.
Thank you.
Yaron:
Solved: https://superuser.com/questions/1230810/vbs-select-one-file-in-a-folder/1231091#1231091
Navigation
[0] Message Index
Go to full version