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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA code to check if a program is currently running on the pc

Status
Not open for further replies.

markronz

IS-IT--Management
Mar 20, 2007
93
US
Hello everyone-
I'm trying to write some code that emails some text to someone. In my office we use Lotus Notes. I've wrote the code and it works fine as long as Lotus Notes is open on the machine. But if Lotus Notes isn't open, my code pastes the information all over the place, and doesn't work correctly. So ideally, what I'd like to happen is that in my code, it first checks to see if there's an instance of Notes running. If so, it does my existing code. If not, then it just displays an error message to launch Notes first.

Sorry for the lengthy question. In short: does anyone know how to check to see if a specific program is currently running in VBA code?

Thanks
-Mark
 
I'd try to activate it and if it gives me an error then exit and display a message:
Code:
On Error GoTo lotusNotOpen
lotusOpen = False
AppActivate "Lotus Notes"
AppActivate "Microsoft Excel"
On Error GoTo 0
lotusOpen = True
at the beginning of the sub

Code:
lotusNotOpen:
If Not lotusOpen Then MsgBox "Lotus Notes must be open"
End Sub
at the end.
 
Worked great! Thank you very much Fr33dan!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top