Q. Closing an external application?
I`m trying to write a program that will close an
application after a certain period of time. Running
the program (i.e. Notepad) seems easy, but I have yet
to find a statement to terminate it.
A. You can use SendKeys to close a program. The following
text is taken from the SendKeys example in the online help.
It runs, uses and closes the calculator, but notepad would
be very similar.
ReturnValue = Shell("Calc.exe", 1) .
ppActivate ReturnValue' Activate calc.
For i = 1 To 100
endKeys i & "{+}", True' Send keys
Next i .
endKeys "=", True' Get grand total.
endKeys "%{F4}", True' ALT+F4 closes
(26-Aug-98 Bob Walsh rlwalsh@capecod.net)
A. Place 2 command buttons on a form and then paste this
code into your declarations section.
Press Command1 to start up notepad and Command2 to terminate
it.
Option Explicit
Dim ReturnValue
Private Sub Command1_Click()
ReturnValue = Shell("notepad.exe", 1)
End Sub
Private Sub Command2_Click()
Dim i
ppActivate ReturnValue' Activate notepad.
endKeys "%{F4}", True' Send ALT+F4 to close notepad
End Sub
(26-Aug-98 Rich ryarnell@andrew.cmu.edu)
Downloads
In IE right-click and select 'Save Target As...' or in Netscape
right-click and select 'Save Link As...'
View Plain Text
Not Available
Not Available