cheking if there si an excel process, and use it to open int this instance a book

Posted on 2006-04-21
Last Modified: 2011-08-18

I´m looking for the way to look if there is an excel instance activate to use after thisone to open a book, and not open then a new excel instance.

Question by:1469
    LVL 69

    Expert Comment

    by:Éric Moreau
    Hi 1469,

    you need to use GetObject. See for a sample

    LVL 44

    Accepted Solution

    Hello 1469,

    you could use the code GetObject
    Dim xlApp as Object
    'use a resume next to prevent an error dialog
    on error resume next
    'try to get the running excel
    Set xlApp = GetObject(,"Excel.Application" )
    'now we get an error but the resume next is going to the next line
    if xlApp is Nothing then
      'if there is no excel running create one
      Set xlApp = CreateObject("Excel.Application" )
    end if

    hope this helps a bit

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Introduction This article makes the case for using two modules in your VBA/VB6 applications to provide both case-sensitive and case-insensitive text comparison operations.  Recently, I solved an EE question using the LIKE function.  In order for th…
    This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now