-
Terminating select processes
I have implemented the code found in the article listed below and it works well, but what I want to do, if possible, is to bypass terminating a certain instance of msaccess.exe based on the Application Title or some other static value.
I don't think I can use the PID for this, as it seems to be dynamically assigned each time Access is open (or for any app for that matter). I always want to bypass the instance of Access that is running this code because it always gets terminated by the code.
vbaexpress.com/kb/getarticle.php?kb_id=811
Thanks!
Clint
-
The Win32_Process doesn't have an Application Title property so cannot select a specific instance to terminate based on window title.
-
Thanks for your reply!
Do you know if there is some value associated with Win32_Process that I might be able to use?
Thanks again,
Clint
-
Hi Clint,
There doesn't seem to be :-(. http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
But maybe use something along the lines of:
[VBA]
Option Explicit
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
Private Const WM_CLOSE = &H10
Sub TerminateProgamByWindowTitle()
Dim strWindowName As String
Dim lngWindow As Long
strWindowName = InputBox("Type the Application Text of the program you want close.", "Close program?")
lngWindow = FindWindow(vbNullString, strWindowName)
SendMessage lngWindow, WM_CLOSE, 0, vbNullString
End Sub
[/VBA]
This code finds the window that has the given window title text and
sends the close command to it.
I have NOT fully tested this though. Please use with caution.
-
Much thanks for your time and input!
I think this will work for me.
Thanks again!
Clint
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules