Close external program (1 Viewer)

TylerTand

Registered User.
Local time
Yesterday, 23:45
Joined
Aug 31, 2007
Messages
95
I am using Access 2003 and need a piece of code that will close an externally running program. I use a Shell command to open the program but I can't find any help on closing or killing an external program to Access. You help is greatly appreciated
Tyler
 

PeregrinTook

Registered User.
Local time
Today, 07:45
Joined
Aug 1, 2006
Messages
15
Hey Tyler,

I don't know if there's a safer way to do this, and I personally never use SendKeys - but I reckon this should work...?

Call CloseApp and pass in the desired Application Name as a string:

Code:
Sub CloseApp(pstrAppName As String)

    AppActivate pstrAppName
    Application.SendKeys "%{F4}", True

End Sub

HTH
J
 

TylerTand

Registered User.
Local time
Yesterday, 23:45
Joined
Aug 31, 2007
Messages
95
I have multiple copies of my database at different locations I can successfully use the following piece of code at my home location but at another location it doesn't work

killString = "taskkill /F /IM zapgrab2.exe"
Call Shell(killString, vbHide)

This stops a program named Zapgrab

Is Visual Basic 6 and VBA the same thing? I have searched and found code that supposedly works in VB6 but doesn't seem to work in Access 2003 using VBA.
Thanks for your help with this.

P.S. Bob (Moderator) if you want to Chim in I would appreciate it
 

Users who are viewing this thread

Top Bottom