How to release Excel97 in VS.net 2003

A

Arron

After the following code is finished,I open the Task
manager,but the excel.exe is still running.
How can I release it from memory.
ps.I use vs.net 2003 + excel97
Thank you!!
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
oExcel = CreateObject("Excel.Application")
While myobj.read
oExcel.workbooks.open("C:\123.xls")
oSheet = oExcel.sheets("test")
oExcel.run("bb") 'Call marco
oExcel.save()
oExcel.quit()
GC.Collect()
oSheet = Nothing
oBook = Nothing
oExcel = Nothing
End While
 
B

Bernie Yaeger

Hi Arron,

After oexcel.quit, add this line:
marshal.releasecomobject(oexcel)

HTH,

Bernie Yaeger
 
A

Arron

What is marshal?
I add "marshal.releasecomobject(oexcel)"
but the VS.net said that "marshal is not declared"!!

========================================================
 
B

Bernie Yaeger

Hi Arron,

I'm pretty sure it's part of system.runtime.interopservices. Add this
imports statement:
Imports System.Runtime.InteropServices

Bernie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top