By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,016 Members | 2,265 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,016 IT Pros & Developers. It's quick & easy.

Killing Excel instance

P: n/a
Hi! All,

I am using a ASP.NEt application, wherein i am automating Execl object. I
am not able to destroy the instance, eve if I write this to destroy the
instance of Excel. Please find the code below

GC.Collect(0);
myBook.Close(null,null,null);
myApp.Workbooks.Close();

myApp.Quit();

mySheet = null;
myBook = null;
myApp = null;
May 21 '07 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"Baren" <Ba***@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.com...
I am using a ASP.NEt application, wherein i am automating Execl object.
Server-side automation is not supported by Microsoft, because it doesn't
work:
http://support.microsoft.com/default...US;q257757#kb2

Find another way to do what you need...

--
http://www.markrae.net

May 21 '07 #2

P: n/a
Calling System.Runtime.InteropServices.Marshal.ReleaseComO bject()
with the Excel instance should let you get what you want.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Baren" <Ba***@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.com...
Hi! All,

I am using a ASP.NEt application, wherein i am automating Execl object. I
am not able to destroy the instance, eve if I write this to destroy the
instance of Excel. Please find the code below

GC.Collect(0);
myBook.Close(null,null,null);
myApp.Workbooks.Close();

myApp.Quit();

mySheet = null;
myBook = null;
myApp = null;


May 21 '07 #3

P: n/a
I *really* resisted calling for you, Mark.

:-)

Re the OP's request, something like this:
http://web.peoriadesignweb.com/spreadsheet/

....might be useful.

Their pricing isn't too bad, either.

There's other online spreadsheet programs, too.
That's just one of them.


Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
======================================
"Mark Rae" <ma**@markNOSPAMrae.netwrote in message
news:%2******************@TK2MSFTNGP04.phx.gbl...
"Baren" <Ba***@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.com...
>I am using a ASP.NEt application, wherein i am automating Execl object.

Server-side automation is not supported by Microsoft, because it doesn't work:
http://support.microsoft.com/default...US;q257757#kb2

Find another way to do what you need...

--
http://www.markrae.net

May 21 '07 #4

P: n/a
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:ux**************@TK2MSFTNGP03.phx.gbl...
>I *really* resisted calling for you, Mark.

:-)
I beat you to it... :-)

--
http://www.markrae.net

May 21 '07 #5

P: n/a
You have to use System.Runtime.InteropServices.Marshal.ReleaseComO bject to
manually release COM objects such as Excel.
Garbage collector will release it eventually but you never know when.

----------------------------------

Also be careful (very careful) with statements like that
myApp.Workbooks.Close();

Behind the scene compiler does following

tmp = myApp.Workbooks
tmp.Close()

So the variable tmp is a COM object and will not be released. Bottom line,
you should never have more than one dot in your statement when work with COM
objects.

---------------------------------------

Here is your code rewritten that should close Excel. (it's a pseducode)

myBook.Close(null,null,null);
Marshal.ReleaseComObject(myBook);
myBook = null;
tmp = myApp.Workbooks
tmp.Close();
Marshal.ReleaseComObject(tmp);
tmp = null;
myApp.Quit();
Marshal.ReleaseComObject (myApp);
myApp = null;

George.

"Baren" <Ba***@discussions.microsoft.comwrote in message
news:C9**********************************@microsof t.com...
Hi! All,

I am using a ASP.NEt application, wherein i am automating Execl object. I
am not able to destroy the instance, eve if I write this to destroy the
instance of Excel. Please find the code below

GC.Collect(0);
myBook.Close(null,null,null);
myApp.Workbooks.Close();

myApp.Quit();

mySheet = null;
myBook = null;
myApp = null;

May 21 '07 #6

This discussion thread is closed

Replies have been disabled for this discussion.