M
Marceepoo
Discussions in Word Programming
vbscript not found, Shell & Windows Explorer search automation
The vbscript below works fairly well, but ...
1. I kind of feel that I'm cheating because the script relies on sendkeys,
because I can't find hooks to connect to the fields in the Windows Explorer
Search windows page. (I simplified the script; in practice, I feed the macro
different search paths and search filters, depending on the circumstances.)
Does anyone know where can I find info about automation and how to connect to
to those fields?
2. I can't figure out how to convert the script into vba code so that I
could run it as a macro. (nor could I figure out how to convert the script
into code that would run under visual studio 2008).
3. I tried to use the shell to call the script below, but vba returned a
message that I had used an invalid procedure call or argument:
Sub runFindFilesVbs()
Dim sRetVal As Integer
Dim strCmdLin As String 'chr(34)
strCmdLin =
"C:\Apps\Deeleet01\FindFilesVbScript_CommunitySolution.2008.05.28.vbs"
sRetVal = Shell(strCmdLin, 1) ' This line returned
' a message: Invalid procedure call or argument
End Sub
4. I tried to use the shell to run the following code (that works just fine
in a cmd window), but vba returned a message: File not found:
Sub runSearchBatCmdLin()
Dim sRetVal As String
Dim strCmdLin As String
strCmdLin = "type nul>mt.FND&start mt.FND&del /q /f /a mt.FND"
sRetVal = Shell(strCmdLin, 1) ' This line returned
' a message: File not found
End Sub
I'd be very grateful for any coding suggestions, or suggestions where I
could learn what I'm doing wrong, and what I need to do.
thanks,,,,,,,,,,,,,,,,,,,,,,,,,, marceepoo
Here's the scrpt that works just fine:
Dim objShell, WshShell
Set objShell = WScript.CreateObject("Shell.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
objShell.FindFiles
WScript.Sleep 500
WshShell.AppActivate "Find: All files"
WScript.Sleep 2000
WshShell.SendKeys "%L"
WScript.Sleep 2000
WshShell.SendKeys "%L"
WScript.Sleep 2000
WshShell.SendKeys "k:\zmani"
WScript.Sleep 2000
WshShell.SendKeys "%o"
WScript.Sleep 1000
WshShell.SendKeys "%o"
WScript.Sleep 1000
WshShell.SendKeys "*.pdf"
WScript.Sleep 3000
WshShell.SendKeys "{enter}"
'Alt-O = Filename/filemask field, "All or part of the file name:",
' The Alt-O field is where you land in Windows Explorer, when
' you run the code lines above this comment.
'Alt-L = "Lookin in:" field
'Alt-R = "Search" button
vbscript not found, Shell & Windows Explorer search automation
The vbscript below works fairly well, but ...
1. I kind of feel that I'm cheating because the script relies on sendkeys,
because I can't find hooks to connect to the fields in the Windows Explorer
Search windows page. (I simplified the script; in practice, I feed the macro
different search paths and search filters, depending on the circumstances.)
Does anyone know where can I find info about automation and how to connect to
to those fields?
2. I can't figure out how to convert the script into vba code so that I
could run it as a macro. (nor could I figure out how to convert the script
into code that would run under visual studio 2008).
3. I tried to use the shell to call the script below, but vba returned a
message that I had used an invalid procedure call or argument:
Sub runFindFilesVbs()
Dim sRetVal As Integer
Dim strCmdLin As String 'chr(34)
strCmdLin =
"C:\Apps\Deeleet01\FindFilesVbScript_CommunitySolution.2008.05.28.vbs"
sRetVal = Shell(strCmdLin, 1) ' This line returned
' a message: Invalid procedure call or argument
End Sub
4. I tried to use the shell to run the following code (that works just fine
in a cmd window), but vba returned a message: File not found:
Sub runSearchBatCmdLin()
Dim sRetVal As String
Dim strCmdLin As String
strCmdLin = "type nul>mt.FND&start mt.FND&del /q /f /a mt.FND"
sRetVal = Shell(strCmdLin, 1) ' This line returned
' a message: File not found
End Sub
I'd be very grateful for any coding suggestions, or suggestions where I
could learn what I'm doing wrong, and what I need to do.
thanks,,,,,,,,,,,,,,,,,,,,,,,,,, marceepoo
Here's the scrpt that works just fine:
Dim objShell, WshShell
Set objShell = WScript.CreateObject("Shell.Application")
set WshShell = WScript.CreateObject("WScript.Shell")
objShell.FindFiles
WScript.Sleep 500
WshShell.AppActivate "Find: All files"
WScript.Sleep 2000
WshShell.SendKeys "%L"
WScript.Sleep 2000
WshShell.SendKeys "%L"
WScript.Sleep 2000
WshShell.SendKeys "k:\zmani"
WScript.Sleep 2000
WshShell.SendKeys "%o"
WScript.Sleep 1000
WshShell.SendKeys "%o"
WScript.Sleep 1000
WshShell.SendKeys "*.pdf"
WScript.Sleep 3000
WshShell.SendKeys "{enter}"
'Alt-O = Filename/filemask field, "All or part of the file name:",
' The Alt-O field is where you land in Windows Explorer, when
' you run the code lines above this comment.
'Alt-L = "Lookin in:" field
'Alt-R = "Search" button