Monday, April 30, 2007

Generic Function to Check if Application is Running

Check if Instance of Application is Running

' Change the sApp Variable to check the Application you needed

Sub Check_If_Application_Is_Open()

'Check if Instance of MS Word is Running in the machine

sApp = "Word.Application"
If IsAppRunning(sApp) = True Then
MsgBox "Application is Running"
MsgBox "Application is NOT Running. Let me create my own"
' Create a new instance
Set oApp = CreateObject(, sApp)
End If

End Sub

' Generalized Function to Check if an Instance of Application is running in the machine
Function IsAppRunning(ByVal sAppName) As Boolean
Dim oApp As Object
On Error Resume Next
Set oApp = GetObject(, sAppName)
If Not oApp Is Nothing Then
Set oApp = Nothing
IsAppRunning = True
End If
End Function

' Generic Function to Check if Application is Running, Visual Basic GetObject, VBA GetObject, VB6 GetObject


  1. Anonymous9:20 AM

    Worked like a charm! Thank you so much...

    -Excel User, Bay Area, CA

  2. Anonymous9:56 AM

    yesss! it works for me.. =)

    but, is it possible to check if the excel (or any other application) is not responding (application hang)? i have the macro to check the total time but i dont know how to determine if an application is not responding. thanks in advance..

    hoping to get the answer asap.. thanks a lot ^_^

  3. Anonymous6:29 AM

    beautiful thanks for sharing ^^


Share on Facebook
Related Posts Plugin for WordPress, Blogger...
Download Windows Live Toolbar and personalize your Web experience! Add custom buttons to get the information you care about most.