View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default How do i close i an application by VBA? (Repost)

Also, see your first posting of this question. You have an answer from RB
Smissaert.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Perhaps you can do something by using these articles and their links:

http://support.microsoft.com/kb/129796/EN-US/

http://support.microsoft.com/default...b;en-us;176391

http://support.microsoft.com/default...b;en-us;129797

--
Regards,
Tom Ogilvy

"Avi" wrote in message
...
Hello,

I open an application via this code that works fine
Sub LaunchCaptureExpress()
Dim RetVal As Long
RetVal = Shell("C:\Program Files\Capture
Express\capexp.exe", vbNormalFocus)
End Sub

How do i close it???

I was given the following solution by "chijanzen", but i get an error
message " AciveX does'nt support object" that refers to "Set WshShell =
CreateObject("Wscript.Shell")"

close the Windows after 10 seconds

Sub LaunchCaptureExpress()
Dim WshShell As Object
Dim oExec As Object
Set WshShell = CreateObject("Wscript.Shell")
Set oExec = WshShell.Exec("C:\Program Files\Capture
Express\capexp.exe")
DoEvents
Application.Wait (Now + TimeValue("0:00:10"))
oExec.Terminate
Set WshShell = Nothing
Set oExec = Nothing
End Sub



Could you help?

Thanks a lot