cancel
Showing results for 
Search instead for 
Did you mean: 

Sbo - Excel/Word

former_member344412
Participant
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (5)

Answers (5)

former_member344412
Participant
0 Kudos

Tks You All

It works Now with this code :

ExcelDocument = Nothing

ExcelApplication.Quit()

ExcelApplication = Nothing

GC.Collect()

former_member344412
Participant
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Ribeiro Santos

former_member344412
Participant
0 Kudos

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

Former Member
0 Kudos

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

former_member344412
Participant
0 Kudos

Hi,

I tried with your code but I have the same trouble.

I think that I have a mistake in my program.

Tks for your answer.

Former Member
0 Kudos

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