Results 1 to 2 of 2
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Melbourne, Australia
    Thanked 0 Times in 0 Posts

    check if application running

    Hi ya -
    from word 97 - I need to check if a certain application is running/open (the application being Adobe Acrobat Distiller).

    I dont know if you can do this with code but...
    If not running - fire up app - else then I will display message for user.

    I did a search & found the following code by kevin

    objWord = GetObject("Word.application")
    If objWord.Tasks.Exists("App Name") Then
    bla bla
    End If
    Set objWord = Nothing

    I have amended the code below but keep getting a run-time error Autotmation - on line:
    objDistiller = GetObject("AcroDist.application")

    Dim objDistiller As Object
    If blnLoggedOnCitrix = True And PDFPrinterFound = True Then

    objDistiller = GetObject("AcroDist.application")
    If objDistiller.Tasks.Exists("AcroDist.exe") Then

    MsgBox "Distiller IS running"

    MsgBox "Distiller not running"
    Shell "AcroDist.exe"
    End If
    End If

    I have tried to set the path
    objDistiller = GetObject("C:Program FilesDistiler.AcroDist.exe")
    but still get an error.

    Should I be using the following sytnax with a shell to open?
    If Application.Tasks.Exists("AcroDist.application") Then

    Do I need to have & declare necessary API routines for the code to work.
    Please explain

    TIA Diana

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    New York, NY
    Thanked 29 Times in 27 Posts

    Re: check if application running

    Hi Diana,

    The Tasks code gets run in Word, not from another app.

    For application name, you need to determine the appropriate name (not the same as the name of the .exe file).
    A quick way to get the appropriate Task name would be to run the following code in Word:

    Sub PrintTasksList()
    Dim aTask As Task
    For Each aTask In Tasks
    Debug.Print aTask.Name
    Next aTask
    End Sub

    Kevin's example described a method for using automation to run a Tasks check in Word, from another application. But since you're already working in Word, you don't need to worry about that part.

    Here's some more code that may be useful:
    Sub CallIsAppRunning()

    If bIsAppRunning("Microsoft Outlook") Then
    MsgBox "Yup, OL is running!"
    End If
    End Sub
    Public Function bIsAppRunning(ByVal vsAppName As String) As Boolean
    Dim aTask As Task
    bIsAppRunning = False
    For Each aTask In Tasks
    If aTask.Name = vsAppName Then
    bIsAppRunning = True
    Exit Function
    End If
    Next aTask
    End Function


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts