Hi. I've modified a vb script example from the msdn page to start my own script. When I put it inside my VB6 program and try to run it like this:
Dim WshShell
Dim WScript
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\Hewlett-Packard\Digital Imaging\bin\Hpqdirec.exe"""
WScript.sleep 1000
WshShell.AppActivate "HP Director"
WScript.sleep 100
WshShell.SendKeys "%{s}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "{DOWN 1}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 2500
it says: "Object required", referencing my Set WshShell = WScript.CreateObject("WScript.Shell") line. I then changed only the first two lines to:
Dim WshShell
Dim WScript
Set WshShell = CreateObject("WScript.Shell")
Set WScript = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\Hewlett-Packard\Digital Imaging\bin\Hpqdirec.exe"""
WScript.sleep 1000
WshShell.AppActivate "HP Director"
WScript.sleep 100
WshShell.SendKeys "%{s}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "{DOWN 1}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 2500
It then stops me at the WScript.sleep 1000 line, and says: Object doesn't support this property or method." I'm confused as to why the sleep method works in the example at msdn, but not in my script, once I've placed it into my VB6 program. I've gone to got an appropriate download, and looked for guidance there, as was suggested to me previously, but haven't been able to figure out why the sleep method (and the AppActivate, I suspect, too) isn't working. Any help with this issue would be greatly appreciated. Thanks.
cold25
Dim WshShell
Dim WScript
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\Hewlett-Packard\Digital Imaging\bin\Hpqdirec.exe"""
WScript.sleep 1000
WshShell.AppActivate "HP Director"
WScript.sleep 100
WshShell.SendKeys "%{s}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "{DOWN 1}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 2500
it says: "Object required", referencing my Set WshShell = WScript.CreateObject("WScript.Shell") line. I then changed only the first two lines to:
Dim WshShell
Dim WScript
Set WshShell = CreateObject("WScript.Shell")
Set WScript = CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\Hewlett-Packard\Digital Imaging\bin\Hpqdirec.exe"""
WScript.sleep 1000
WshShell.AppActivate "HP Director"
WScript.sleep 100
WshShell.SendKeys "%{s}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "{DOWN 1}"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 500
WshShell.SendKeys "~"
WScript.sleep 2500
It then stops me at the WScript.sleep 1000 line, and says: Object doesn't support this property or method." I'm confused as to why the sleep method works in the example at msdn, but not in my script, once I've placed it into my VB6 program. I've gone to got an appropriate download, and looked for guidance there, as was suggested to me previously, but haven't been able to figure out why the sleep method (and the AppActivate, I suspect, too) isn't working. Any help with this issue would be greatly appreciated. Thanks.
cold25