Determine if an application is available

 2000-04-12    VBA programming    2    59

You can use the two functions below to determine if an application is already running or if it is available on the host computer:

Function ApplicationIsRunning(ApplicationClassName As String) As Boolean
' returns True if the application is running
' example: If Not ApplicationIsRunning("Outlook.Application") Then Exit Sub
Dim AnyApp As Object
  On Error Resume Next
  Set AnyApp = GetObject(, ApplicationClassName)
  ApplicationIsRunning = Not AnyApp Is Nothing
  Set AnyApp = Nothing
  On Error GoTo 0
End Function

Function ApplicationIsAvailable(ApplicationClassName As String) As Boolean
' returns True if the application is available
' example: If Not ApplicationIsAvailable("Outlook.Application") Then Exit Sub
Dim AnyApp As Object
  On Error Resume Next
  Set AnyApp = CreateObject(ApplicationClassName)
  ApplicationIsAvailable = Not AnyApp Is Nothing
  Set AnyApp = Nothing
  On Error GoTo 0
End Function


Leave a comment:

Your comment will only be published after it has been moderated and found spam free.
Your e-mail address will only be used to display your Gravatar.

OPE | 2009-09-11 14:17:50 (GMT)

Hi!

I have no more information about that than is available here:
http://msdn.microsoft.com/en-us/library/e9waz863.aspx

Robert | 2009-09-10 20:33:07 (GMT)

Hi,
How would I use this to determine the status of a Non-Microsoft application? I tried using the name of the process in Task Manager, but that didn't work.
Thanks!
Robert