jeisch,
I have never heard of using appName for anything except discovering a browser name, so dhaveedh, if you could explain a little more clearly how this works, I'd enjoy learning about it......
In the meantime, here's another way (which I use to kill this annoy-o-gram that my employer sends each time I log in. It is actually a VB program that I run in my startup, but there's no reason you could not run it in VBA.
You can take out the sleep stuff, I am just including it fyi. The only other thing you really need to change is where it says:
hWnd = findwindow(vbNullString, " KDOT COMPUTERS AND NETWORKS ARE FOR OFFICIAL BUSINESS"
Change the " KDOT COMPUTERS...." to "ADOBE ACROBAT"
Then it will find the handle of the thread that has "ADOBE ACROBAT" in its title bar, and close the app window, which will end the application.
'......................This part of the code goes
' in the general declarations
Option Explicit
Public Const WM_CLOSE = &H10
Declare Function findwindow Lib "user32.dll" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
'..................... This is just a standard private sub
Private Sub KillApp()
Dim hWnd As Long
Dim intCtr As Integer
' Wait for up to 1 minute to find warning.exe window handle
For intCtr = 1 To 120
hWnd = findwindow(vbNullString, " KDOT COMPUTERS AND NETWORKS ARE FOR OFFICIAL BUSINESS"
Select Case hWnd
Case 0
' Window handle not found
' Wait 500 milliseconds, then look again
Sleep 500
DoEvents
Case Else
' Window handle found
' Leave warning message up for 5 seconds
Sleep 5000
'Close the App Window (which ends the app)
Call SendMessage(hWnd, WM_CLOSE, 0&, 0&)
Exit For
End Select
Next
End Sub
This code works under Win98, Win2K, WinNT4.0, WinXP.
Good luck,
Tranman