Results 1 to 2 of 2
2004-09-12, 21:11 #1
- Join Date
- Feb 2001
- Yilgarn region of Toronto, Ontario
- Thanked 0 Times in 0 Posts
Terminate a SHELLed task? (office97)
Is there a <font color=red>simple</font color=red> way to terminate a SHELLed task? (Simple as in "not getting into complex API calls"). The VBA Help is great at launching task, and obtaining the RetVal, but gives no hint as to how to rein in an unleashed beast.
The code below shells out to a browser and pulls up a web page. I want to gaze (in silent admiration!) at the web page (but it could be a Word document or an Email message ...) for a moment, and have the VBA code terminate the task and move on to the next page.
Dim strWebPlaces As String
strWebPlaces = "C:GreavesAdminWeb2Go"
Dim strFile As String
strFile = Dir(strWebPlaces & "*.htm*")
Dim strDestination As String
strDestination = "http://www.chrisgreaves.com/" & strFile
While strFile <> ""
Dim retval As Long
retval = Shell("C:Program FilesMozilla Firefoxfirefox.exe " & strDestination)
'????? In here, pause for two seconds, then terminate the Browser program??????
strFile = Dir
2004-09-12, 22:54 #2
- Join Date
- Dec 2000
- Sacramento, California, USA
- Thanked 1 Time in 1 Post
Re: Terminate a SHELLed task? (office97)
You can use the ProcessID returned by the Shell command to activate the application and then use SendKeys to send an Alt+F4 to close the window.