+ Reply to Thread
Results 1 to 6 of 6

How to check and see if an application (exe) is already running

Hybrid View

  1. #1
    Registered User
    Join Date
    07-22-2010
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    71

    How to check and see if an application (exe) is already running

    Hi There,

    I need your help,

    What would the vba code if I wanted to check and see if an application (ie. applicationA.exe) was already running?

    I'd ideally like to have a MSGBOX popup and say "The application is already running" if the application is not running, load it.

    Much thanks and appreciation for all your help.

    Cheers,

    Jay
    Last edited by jason_kelly; 11-30-2010 at 03:06 PM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to check and see if an application (exe) is already running

    Look into Word's VBA: collection Tasks.



  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How to check and see if an application (exe) is already running

    Maybe this might help
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Registered User
    Join Date
    07-22-2010
    Location
    Ontario
    MS-Off Ver
    Excel 2003
    Posts
    71

    Re: How to check and see if an application (exe) is already running

    The answer to this question can be found by going to:

    http://www.bigresource.com/Tracker/Track-vb-gJwsDJqtCA/

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: How to check and see if an application (exe) is already running

    So what about:

    Sub snb()
      On Error Resume Next
      AppActivate "Microsoft Word"
      MsgBox "Word is " & IIf(Err.Number = 0, "already ", "not ") & "running"
    End Sub

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: How to check and see if an application (exe) is already running

    Hello

    You may be interested in this method using the WMI instead of the API.
    'Written: November 30, 2010
    'Author: Leith Ross
    'Summary: Count the instances of a running executable program
    
    Sub ShowProgramCount()
    
      Dim Cnt As Long
      Dim colProcesses As Variant
      Dim Msg As String
      Dim objSWbemServices As Object
      Dim objProcess As Object
      Dim ProgramX As String
      Dim ThisComputer As String
    
        ProgramX = InputBox("Enter the name of the exectable file below.")
        If ProgramX = "" Then Exit Sub Else ProgramX = LCase(ProgramX)
        
        ThisComputer = "."
        
        Set objSWbemServices = GetObject("winmgmts:\\" & ThisComputer)
        Set colProcesses = objSWbemServices.InstancesOf("Win32_Process")
        
        For Each objProcess In colProcesses
           'Msg = Msg & Process.Name & vbCrLf
           If LCase(objProcess.Name) Like ProgramX Then
               Cnt = Cnt + 1
           End If
        Next objProcess
    
        MsgBox "Number of '" & ProgramX & "' Programs Open: " & Cnt
    
      Set objProcess = Nothing
      Set objSWbemServices = Nothing
    
    End Sub
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1