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 6246813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T12:45:32+00:00 2026-05-24T12:45:32+00:00

I am working on VIsusal studio application. I am trying to open excel and

  • 0

I am working on VIsusal studio application. I am trying to open excel and read the data.and save the excel to different location.

Then when i break/end the applcation and re-run it says “excel is being modified by another user.Open as readonly “

When i go to prcoess and kill it using “Task Manager” it works again.

So i did through code:

Private Sub releaseObject(ByVal obj As Object)
    Try
        System.Runtime.InteropServices.Marshal.ReleaseComObject(obj)
        obj = Nothing

        Dim proc As System.Diagnostics.Process
        For Each proc In System.Diagnostics.Process.GetProcessesByName("EXCEL")
            proc.Kill()
        Next
    Catch ex As Exception
        obj = Nothing
    Finally
        GC.Collect()
    End Try
End Sub

Still it is throwing the same message “excel is being modified by another user.Open as readonly “

PLease help what need to be done for this.

  • 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-24T12:45:33+00:00Added an answer on May 24, 2026 at 12:45 pm

    The big problem with automation in Excel is that you need to ensure you close every single reference whenever you use them (by calling ReleaseComObject on it).

    For example, the following code will cause Excel to stay open:

    var range;
    range = excelApplication.Range("A1");
    range = excelApplication.Range("A2");
    System.Runtime.InteropServices.Marshal.ReleaseComObject(range)
    range = Nothing
    

    This is because there is still a reference left over from the call to get range “A1”.

    Therefore, I would recommend writing a wrapper around the Excel class so that any access to, e.g., a range frees any previous ranges accessed before accessing the new range.

    For reference, here is the code I used to release COM objects in the class I wrote:

    Private Sub ReleaseComObject(ByVal o As Object)
        Try
            If Not IsNothing(o) Then
                While System.Runtime.InteropServices.Marshal.ReleaseComObject(o) > 0
                    'Wait for COM object to be released.'
                End While
            End If
            o = Nothing
        Catch exc As System.Runtime.InteropServices.COMException
            LogError(exc) ' Suppress errors thrown here '
        End Try
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Visual Studio 2010 (C#) application is working, and I've been trying to deploy
I am working in Visual Studio 2008 on an ASP.NET application, which has been
When working with an ASP.NET application in Visual Studio 2008, my errors window often
I'm working on a Web Application in Visual Studio 2008. For some reason the
I'm working on an old web application in Visual Studio .Net 2003 (yeeich) and
I am currently working on an asp.net application in Visual Studio 2005. I would
I'm currently working on a small web application using Visual Studio 2008 Express. I'm
We are working on a Windows Mobile 6.5 application in Visual Studio 2008. The
Working in Visual Studio 2008. I'm trying to draw on a PNG image and
I'm trying to get client validation working on my asp.net mvc 2 web application

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.