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. EXCEL.EXE is not getting killed

EXCEL.EXE is not getting killed

Scheduled Pinned Locked Moved C / C++ / MFC
c++testingtoolshelpquestion
10 Posts 5 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.
  • K Offline
    K Offline
    KTTransfer
    wrote on last edited by
    #1

    I am working on Excel automation using VC++(unmanaged). Following are the two issues: 1. Whenever Excel is closed , Excel.EXE is not getting closed. My application should track opening and closing of Excel. I released application pointer(Excel::_ApplicationPtr) but same problem. I googled and got few solutions, but nothing worked. I tried : Excel::_ApplicationPtr XL. XL->Quit(); XL->Release(); XL = NULL; but none of these worked. 2. Is there any callback which tracks excel.exe is closed? Please give me clue to solve these issues. Regards, KTTransfer.

    M T D 3 Replies Last reply
    0
    • K KTTransfer

      I am working on Excel automation using VC++(unmanaged). Following are the two issues: 1. Whenever Excel is closed , Excel.EXE is not getting closed. My application should track opening and closing of Excel. I released application pointer(Excel::_ApplicationPtr) but same problem. I googled and got few solutions, but nothing worked. I tried : Excel::_ApplicationPtr XL. XL->Quit(); XL->Release(); XL = NULL; but none of these worked. 2. Is there any callback which tracks excel.exe is closed? Please give me clue to solve these issues. Regards, KTTransfer.

      M Offline
      M Offline
      Madhu Nair 0
      wrote on last edited by
      #2

      Just try this - Set the 'Visible' property to TRUE and then call Quit method. -- Its a guess, if not worked, you may have to find the EXCEL process and terminate the process using TerminateProcess function.

      1 Reply Last reply
      0
      • K KTTransfer

        I am working on Excel automation using VC++(unmanaged). Following are the two issues: 1. Whenever Excel is closed , Excel.EXE is not getting closed. My application should track opening and closing of Excel. I released application pointer(Excel::_ApplicationPtr) but same problem. I googled and got few solutions, but nothing worked. I tried : Excel::_ApplicationPtr XL. XL->Quit(); XL->Release(); XL = NULL; but none of these worked. 2. Is there any callback which tracks excel.exe is closed? Please give me clue to solve these issues. Regards, KTTransfer.

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

        Are you calling GC.Collect()?

        1 Reply Last reply
        0
        • K KTTransfer

          I am working on Excel automation using VC++(unmanaged). Following are the two issues: 1. Whenever Excel is closed , Excel.EXE is not getting closed. My application should track opening and closing of Excel. I released application pointer(Excel::_ApplicationPtr) but same problem. I googled and got few solutions, but nothing worked. I tried : Excel::_ApplicationPtr XL. XL->Quit(); XL->Release(); XL = NULL; but none of these worked. 2. Is there any callback which tracks excel.exe is closed? Please give me clue to solve these issues. Regards, KTTransfer.

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          It must have something to do with the way you are accessing Excel's type library. I've got several Excel automation projects that close Excel just fine. The only difference is that they don't use the #import directive. The one that does use #import simply calls app->Quit().

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          T K 2 Replies Last reply
          0
          • D David Crow

            It must have something to do with the way you are accessing Excel's type library. I've got several Excel automation projects that close Excel just fine. The only difference is that they don't use the #import directive. The one that does use #import simply calls app->Quit().

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            T Offline
            T Offline
            T2102
            wrote on last edited by
            #5

            Again see below... I have had this error before. I have code to controls add-in installation to avoid warnings from one xla referencing another. // The following line is necessary to be sure that app object is released when we finish, because // the Garbage Collector is non-deterministic and by default can leave app unreleased. System::GC::Collect(); System::GC::WaitForPendingFinalizers(); //GetActiveObject Error is this line is excluded

            D 1 Reply Last reply
            0
            • T T2102

              Again see below... I have had this error before. I have code to controls add-in installation to avoid warnings from one xla referencing another. // The following line is necessary to be sure that app object is released when we finish, because // the Garbage Collector is non-deterministic and by default can leave app unreleased. System::GC::Collect(); System::GC::WaitForPendingFinalizers(); //GetActiveObject Error is this line is excluded

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              This is managed code. I think the OP is using unmanaged code.

              "One man's wage rise is another man's price increase." - Harold Wilson

              "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

              T G 2 Replies Last reply
              0
              • D David Crow

                This is managed code. I think the OP is using unmanaged code.

                "One man's wage rise is another man's price increase." - Harold Wilson

                "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                T Offline
                T Offline
                T2102
                wrote on last edited by
                #7

                Then are you using the following? //Release the no-longer-needed IUnknown... if (pUnk) pUnk->Release(); //... Add your automation code for Excel here ... //Release pDisp when no longer needed... if (pDisp) pDisp->Release(); //Cleanup COM... CoUninitialize();

                D 1 Reply Last reply
                0
                • T T2102

                  Then are you using the following? //Release the no-longer-needed IUnknown... if (pUnk) pUnk->Release(); //... Add your automation code for Excel here ... //Release pDisp when no longer needed... if (pDisp) pDisp->Release(); //Cleanup COM... CoUninitialize();

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  Ted2102 wrote:

                  Then are you using the following?

                  No, I use smart pointers whenever possible.

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  1 Reply Last reply
                  0
                  • D David Crow

                    It must have something to do with the way you are accessing Excel's type library. I've got several Excel automation projects that close Excel just fine. The only difference is that they don't use the #import directive. The one that does use #import simply calls app->Quit().

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    K Offline
                    K Offline
                    KTTransfer
                    wrote on last edited by
                    #9

                    Then instead of #import what else we can use to include? I tried making it visible and then used quit but no use. It's not getting killed.

                    1 Reply Last reply
                    0
                    • D David Crow

                      This is managed code. I think the OP is using unmanaged code.

                      "One man's wage rise is another man's price increase." - Harold Wilson

                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                      G Offline
                      G Offline
                      gg4237
                      wrote on last edited by
                      #10

                      If you don't want to bother with this kind of problems in managed world, you should take a look at GemBox.Spreadsheet .NET Excel library. It is lightweight library for reading and writing XLS, XLSX, ODS, CSV and HTML files, and it doesn't use Excel Interop.

                      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