Skip to Content

Sbo - Excel/Word

Hello,

I create an excel file with sbo data in a little program with SDK Vb.net

But even if Excel is closed, the excel process still running.

In VB, I have write those line in order to release object but no more change :

System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApplication) System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelDocument)

Could you help me please.

L.P.

Add a comment
10|10000 characters needed characters exceeded

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2005 at 12:59 PM

    I don´t know why, but if you call GC.Collect() 2x at the end of your code, it works.

    ...

    System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApplication)

    ExcelDocument = Nothing

    ExcelApplication = Nothing

    GC.Collect()

    GC.Collect()

    Ribeiro Santos

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 11, 2005 at 03:59 PM

    Hi,

    Try set the excel object to nothing.

    I tried with

    Dim oExcel As Excel.Application

    oExcel = New Excel.Application

    oExcel.Visible = True

    oExcel.Quit()

    System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)

    oExcel = Nothing

    and work fine.

    See

    http://support.microsoft.com/?kbid=317109

    Ribeiro Santos

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member PIERRE BARRET

      Hi,

      I agree with Ribeiro, but would like to add that all references need to be closed and set to nothing. So if there is still a reference to a workbook, the com-object still has a reference count of 1 and will probably stay in meory.

      So close workbook and set object variablke to nothing etc.

      Regards,

      Jacques

  • Posted on Jan 12, 2005 at 09:52 AM

    Hi,

    I try to close and set to nothing all Excel object but it is the same.

    I have the same code for word and it work fine. I don't find where is the problem for excel 😔

    Tks again

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jan 12, 2005 at 10:46 AM

    Could you put some example of code that get this problem?

    Ribeiro Santos

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 12, 2005 at 11:57 AM

    Here is my code

    Public ExcelApplication As Excel.Application

    Public ExcelDocument As Excel.Workbook

    -


    ExcelApplication = New Excel.Application

    -


    ExcelDocument = ExcelApplication.Workbooks.Open(path + fichier, , , , , , , , , , , , )

    -


    ExcelDocument.SaveAs(filename:=s)

    ExcelApplication.Workbooks.Close()

    ExcelDocument = ExcelApplication.Workbooks.Open(ini.files)

    ExcelApplication.Visible = True

    -


    ExcelApplication.Quit()

    System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApplication)

    ExcelDocument = Nothing

    ExcelApplication = Nothing

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi,

      Have you tried this order yet?

      ExcelDocument = Nothing

      ExcelApplication.Quit()

      ExcelApplication = Nothing

      System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApplication)

      Seems to me as if the reference to the document is still there when you do the application.quit

      If this doesn't work, I'll have to search through some of my code, because I remember having something similar in an asp.net project.

      Hth,

      Jacques

  • Posted on Jan 12, 2005 at 01:21 PM

    Tks You All

    It works Now with this code :

    ExcelDocument = Nothing

    ExcelApplication.Quit()

    ExcelApplication = Nothing

    GC.Collect()

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.