Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VB - How do I close an outside application 1

Status
Not open for further replies.

kwill

Technical User
Aug 15, 2001
49
US
How do I close an outside application(an exe)that I've previously opened with a shell command? I thought it would be quit "c:\xxx.exe", but that no worky.
 
messy way of doing it would be using the send keys function. or what is the app ? if it is amother MS app then open it with the create object command and you can close it in code /?

 
You could use the FindWindow and SendMessage API calls

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

hWnd = FindWindow(vbNullString, MsgTitle)
Call SendMessage(hWnd, WM_CLOSE, 0, ByVal 0&)

 
Hi I tried this code but the WM_CLOSE constant is empty... maybe. If I must put the constant in my code what is the value?

Const WM_CLOSE = ???
 
Paco75,

Public Const WM_CLOSE = &H10

Justin - Thanks, that just may come in handy and worth a star.


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top