Loading
Ozgrid Excel Help & Best Practices Forums

Excel Video Tutorials / Excel Dashboards Reports



Results 1 to 5 of 5

Thread: Check if an Application is running

  1. #1
    Join Date
    16th August 2005
    Location
    London
    Posts
    55

    Check if an Application is running

    Hi all, hope you can help me out here.

    From Excel, I'm writing another macro to send Lotus Notes emails, Add to Notes Doc libraries etc. However, I'm now attempting to automate the whole process. As a result, at the very start of the procedure, I want a function to run to test to see if the Lotus Notes Application is already open.

    I thought I would be able to use the
    VB:
    GetObject("","Notes.NotesSession") 
    
    
    or
    VB:
    GetObject("","Notes.Application") 
    
    
    However, these start the application if it is not already running. Is there a way around this?

    I've also tried to use the FindWindow API call however, depending where a user is within Lotus Notes, the application caption changes so this API call can't really be used.

    Any suggestions would be much appreciated.
    "Why write code when you can copy and paste someone elses?"

  2. #2
    Join Date
    24th March 2003
    Location
    Stuttgart, Germany
    Posts
    24

    Re: Check if an Application is running

    Hi,

    I try to solve a similar problem. I have to check via Excel VBA if Outlook is running before another macro tries to send a mail. I found a workaround to test, wether Outlook is running or not (see code). The problem for me: if outlook is not running, I get an error message which I am not able to handle via "on error" (this is why I marked th "error" code as comment). If I solve the "error"....

    Maybe this could be a start...

    Urs



    VB:
    Sub test_if_outlook_is_running() 
         
         'On Error GoTo errorhandler
         
        Dim appOL As Outlook.Application 
        Dim a As String 
         
        Set appOL = CreateObject("Outlook.Application") 
         
        MsgBox (appOL.ActiveExplorer) 
         
         'errorhandler:  MsgBox ("You have to start Outlook first")
         '  Exit Sub
         
    End Sub 
    
    

    Excel Video Tutorials / Excel Dashboards Reports


  3. #3
    Join Date
    12th July 2006
    Location
    Cincinnati, OH
    Posts
    30

    Re: Check if an Application is running

    I found some code that might help you out. Try this and see if it works for you.

    Place this code right after your declarations: (Don't forget to replace nSession with the name of the variable that you are using to for your Lotus Notes session.)

    VB:
     
    Dim sessionTest As String 
     
    On Error Goto errorHandler 
    sessionTest = nSession.CommonUserName 
    
    
    Next place this code at the end of the sub.

    VB:
     
    errorHandler: 
     
    If Err = ERR_NOTES_SESSION_NOT_INIT Then 
        MsgBox ("Lotus Notes Is Not Open") 
    Else 
        MsgBox ("Run Time Error " & Str(Err) & ":" & vbCrLf & Err.Description) 
    End If 
    
    

    Excel Video Tutorials / Excel Dashboards Reports


  4. #4
    Join Date
    12th February 2007
    Posts
    4

    Re: Check if an Application is running

    Sorry.. but do you have a working sample..
    Thanks..

    Excel Video Tutorials / Excel Dashboards Reports


  5. #5
    Join Date
    12th July 2006
    Location
    Cincinnati, OH
    Posts
    30

    Re: Check if an Application is running

    I am not sure where I got that code from and am currently using a different method to determine if Lotus Notes is running or not.

    Before I have my program try to send an email, I have it run this code first.

    VB:
     
    Sub checkIfNotesIsRunning() 
        On Error Goto notesIsNotRunning 
        AppActivate ("Notes") 
        Call sendEmail 
        Exit Sub 
         
    notesIsNotRunning: 
        Dim notesErr, notesBox 
         
        notesErr = "This program requires Lotus Notes to be running on your computer." & vbCrLf & vbCrLf 
        notesErr = notesErr & "Please open Lotus Notes and try again." 
        notesBox = MsgBox(notesErr, vbCritical, "Lotus Notes Is Not Open") 
        End 
    End Sub 
    
    
    If Lotus Notes is not running, it ends the program with a warning message.
    If it is running, it calles the sendEmail sub.

    I had to add this code to the beginning of the sendEmail sub to get the focus back on Excel.

    VB:
    AppActivate "Microsoft Excel" 
    Windows("emailGenerator.xls").Activate 
    Sheets("eGen").Select 
    
    
    I have attached a working copy of my email VBA.
    Attached Files. REMINDER! OzGrid accepts no responsibility for ANY adverse effects as a result from downloading attached files. ALWAYS run an up-to-date virus scan and disable macros.
    Last edited by storyM; March 17th, 2007 at 05:17.
    If it can't be done in Excel, it doesn't need to be done at all.

Thread Information

Users Browsing this Thread

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

Possible Answers

  1. Count Active / Instances Of Application Running
    By chrisbryant in forum EXCEL HELP
    Replies: 4
    Last Post: February 4th, 2008, 19:48
  2. Check box running a macro
    By Den in forum EXCEL HELP
    Replies: 4
    Last Post: November 30th, 2005, 03:14
  3. Replies: 6
    Last Post: July 23rd, 2003, 22:49

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
  •  
porno