on 01-11-2005 3:10 PM
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Tks You All
It works Now with this code :
ExcelDocument = Nothing
ExcelApplication.Quit()
ExcelApplication = Nothing
GC.Collect()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
Could you put some example of code that get this problem?
Ribeiro Santos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.