Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7622743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:31:46+00:00 2026-05-31T04:31:46+00:00

I’m writing an application, which accesses Excel file with this code: RBTApplication = new

  • 0

I’m writing an application, which accesses Excel file with this code:

RBTApplication = new Excel.Application();
RBTWorkbooks = RBTApplication.Workbooks;
RBTWorkbook = RBTApplication.Workbooks.Open(
    RBTDataSet.Instance.FilePath, 0, true, 5, "", "", true,
    Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,
    "\t", true, false, 0, true, 1, 0 );
RBTWorksheet = (Excel.Worksheet)RBTWorkbook.Worksheets.get_Item( 1 );
RBTRange = RBTWorksheet.UsedRange;

After I load data that I need, I try to close Excel application with this piece of code:

RBTWorkbook.Close();
RBTApplication.Quit();
RBTWorksheet.ReleaseComObject();
RBTWorkbook.ReleaseComObject();
RBTWorkbooks.ReleaseComObject();
RBTApplication.ReleaseComObject();

My problem is that EXCEL.EXE process is still running.
Simple solution like killing all Excel processes doesn’t sound great, as my process can be one of many spreadsheets used at the same time. This one also affects opening new excel spreadsheets – every opens as read only until I don’t kill this process.

So … how to close this application properly OR kill this specific process (is there any way to get PID from COM object ?). I think I’ve found one (haven’t tried) – get list of excell processes before and after opening new ExcellApp, compare lists (get difference), kill specific process knowing its PID. But this solution doesn’t seem like a proper way of handling COM objects and other applications from within my app.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T04:31:47+00:00Added an answer on May 31, 2026 at 4:31 am

    You are not releasing all your COM objects.

    For example:

    RBTApplication.Workbooks.Open
    

    Will instantiate a Workbooks object, as will:

    RBTWorkbook.Worksheets.get_Item
    

    Instead, use the Worksheets object you have already created:

    RBTWorkbooks = ...
    ...
    RBTWorkbooks.Open(...)
    RBTWorkbooks.get_Item(...)
    

    If your interop requirements are simple, and the interop code is localized, you can get away with carefully making sure you release all COM objects you reference, ideally using try/finally to make sure they are released even if an exception is thrown.

    However it’s very easy for you or a maintenance programmer down the line to forget one, so you might want to look at forcing garbage collection, for example see the answers to this question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.