Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default How do i close i an application by VBA? (Repost)

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




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do i close i an application by VBA? (Repost)


Hello Avi,

The WSH refers to *Windows Scripting Host*. You will need to add a
reference to this library in your VBA project. On the VBA editor
toolbar select "*Tools*" and the "*References...*". Look in the list
for Windows Scripting Host and check it and click OK. Now the code will
run.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=480375

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do i close i an application by VBA? (Repost)

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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How do i close i an application by VBA? (Repost)

Avi,
Here is an additional thought. if you run this

Sub ABC()
Dim WshShell as Object
set WshShell = CreateObject("Wscript_Tom.Shell")
End Sub
and get the same error message on the CreateObject line, then you don't have
the Windows Scripting Host Installed.

The message you cited isn't exactly the same as what I get, but it may be
you are using a non-english version of windows and you were posting a
translation of the message.

--
Regards,
Tom Oglvy

"Leith Ross" wrote
in message ...

Hello Avi,

The WSH refers to *Windows Scripting Host*. You will need to add a
reference to this library in your VBA project. On the VBA editor
toolbar select "*Tools*" and the "*References...*". Look in the list
for Windows Scripting Host and check it and click OK. Now the code will
run.

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile:

http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=480375



  #5   Report Post  
Posted to microsoft.public.excel.programming
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










  #6   Report Post  
Posted to microsoft.public.excel.programming
avi avi is offline
external usenet poster
 
Posts: 195
Default How do i close i an application by VBA? (Repost)

thanks a lot, Tom!

Article nb 2 did the work!!!!

Avi

Avi Benita 054-4660641 wwwAvi Benita 054-4660641 www.avibenita.com
"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








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Close an application? Avi Excel Programming 3 October 28th 05 01:58 PM
Repost Excel Crashes on Workbook close!! James Wellington Excel Programming 3 August 3rd 05 06:31 PM
Close the other application Lulu Excel Programming 1 December 16th 04 05:43 PM
macro to close excel application other than application.quit mary Excel Programming 1 September 14th 04 03:43 PM
Application.Close Nichevo Excel Programming 3 December 23rd 03 03:33 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"