Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Get all running Excel

Get all running Excel

Scheduled Pinned Locked Moved C / C++ / MFC
question
7 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    trioum
    wrote on last edited by
    #1

    I have multiple excel.exe running on my system . When I called GetActiveObject() method then I am able to get only the one excel.exe not all . So please tell me how can I get all the running excel.exe

    Trioum

    G 1 Reply Last reply
    0
    • T trioum

      I have multiple excel.exe running on my system . When I called GetActiveObject() method then I am able to get only the one excel.exe not all . So please tell me how can I get all the running excel.exe

      Trioum

      G Offline
      G Offline
      Garth J Lancaster
      wrote on last edited by
      #2

      from what Ive seen GetActiveObject() is only going to get one instance. If you are looking for a particular instance, you could try looping :- GetActiveObject() Is This instance what Im looking for ? If No CLose the excel instance repeat until you find the excel instance you want I was thinking that you could enumerate windows with Excel in the title, somehow close the ones you dont want (assuming you can detect the one you do want by the window title), then do a GetActiveObject() sorry .. maybe someone else has a better idea

      T 1 Reply Last reply
      0
      • G Garth J Lancaster

        from what Ive seen GetActiveObject() is only going to get one instance. If you are looking for a particular instance, you could try looping :- GetActiveObject() Is This instance what Im looking for ? If No CLose the excel instance repeat until you find the excel instance you want I was thinking that you could enumerate windows with Excel in the title, somehow close the ones you dont want (assuming you can detect the one you do want by the window title), then do a GetActiveObject() sorry .. maybe someone else has a better idea

        T Offline
        T Offline
        trioum
        wrote on last edited by
        #3

        No your idea is failed every time I got the same Excel. And I cannot close the running excel.exe

        Trioum

        G 2 Replies Last reply
        0
        • T trioum

          No your idea is failed every time I got the same Excel. And I cannot close the running excel.exe

          Trioum

          G Offline
          G Offline
          Garth J Lancaster
          wrote on last edited by
          #4

          well, good luck

          1 Reply Last reply
          0
          • T trioum

            No your idea is failed every time I got the same Excel. And I cannot close the running excel.exe

            Trioum

            G Offline
            G Offline
            Garth J Lancaster
            wrote on last edited by
            #5

            btw how did you implement either of my ideas ? and

            trioum wrote:

            And I cannot close the running excel.exe

            why not ? obviously if you cant close any excel instance you dont want then you'll never get to the one you do want.. what do you have so many zombie excel instances ? 'g'

            T 1 Reply Last reply
            0
            • G Garth J Lancaster

              btw how did you implement either of my ideas ? and

              trioum wrote:

              And I cannot close the running excel.exe

              why not ? obviously if you cant close any excel instance you dont want then you'll never get to the one you do want.. what do you have so many zombie excel instances ? 'g'

              T Offline
              T Offline
              trioum
              wrote on last edited by
              #6

              I have to work with mulitple excel files not one dude

              Trioum

              G 1 Reply Last reply
              0
              • T trioum

                I have to work with mulitple excel files not one dude

                Trioum

                G Offline
                G Offline
                Garth J Lancaster
                wrote on last edited by
                #7

                do you know if GetActiveObject() returns a reference to the Excel instance that 'has focus' or 'is currently active' ? If that were the case, AND you could distinguish which excel instance was which by the Window title, then you could build a workable solution a) enumerate all the excel instances and look at their window titles b) force the instance you want (by window title) to come to the front ie give it focus c) then do a GetActive Object somehow I dont think its that easy - the GetActiveObject may have its own way of looking at the ROT or process table, not just the 'active excel instance' - thats confirmed by looking further : MS KB 238975 - http://support.microsoft.com/kb/238975[^] says "NOTE: If there are multiple instances of an automation server running at the same time, the GetActiveObject() API function returns the IDispatch pointer to the instance that was first running." So I dont think you're going to be able to do it :-(

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups