Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Stopping a running app from VB

Posted on 1998-10-09
4
143 Views
Last Modified: 2010-04-30
I need to stop and restart (reboot) another application from within my VB app. For example, 'myapp' needs to stop stop MS Word and then restart it. Does anyone know the best way to do this?

Thanks
0
Comment
Question by:joe_s
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
waty earned 100 total points
ID: 1439057
Get the HWND of the application, and send a close message :

Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Private Const WM_CLOSE = &H10&


Call PostMessage(nHWND, WM_CLOSE, NULL, NULL)

0
 
LVL 14

Expert Comment

by:waty
ID: 1439058
To find the hwn of the application :

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


   nHwnd = FindWindow("Your Program", vbNullString)

0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1439059
Use "OpusApp" for word
0
 

Author Comment

by:joe_s
ID: 1439060
Thanks, That's just what I needed.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question