473,386 Members | 1,796 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Killing Excel instance

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
5 3817
"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
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
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
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
0
by: net guest via DotNetMonster.com | last post by:
Hi, i am facing a lot of problems in killing the orphan excel instances. I approached one method like killing the Excel Orphan with processID. I am getting all the Processess that are running...
3
by: kunal.kewalramani | last post by:
I'm opening an Excel file using ASP.NET, but Excel process remains it is not killed, I tried killing it by using Quit() that is also not working, if anybody have any solution for this please help me...
5
by: Wenke Ji | last post by:
Hi I open a Excel workbook using below API: Set ExcelServer = CreateObject("EXCEL.Application") Set TargetWorkbook = ExcelServer.Workbooks.Open (CurrentBook) Befor the programm exit , I use...
2
by: tony.newsgrps | last post by:
Hi there, I'm trying to understand the impact of killing a process that owns a system mutex (used to ensure there is only 1 instance of my program running) Here is my code pretty much: try...
16
by: alexia.bee | last post by:
Hi all, In some weird reason, excel instance won;t die if i remove the comment from 4 lines of setting values into struct. here is a snipcode public...
9
by: Doug Glancy | last post by:
I got the following code from Francesco Balena's site, for disposing of Com objects: Sub SetNothing(Of T)(ByRef obj As T) ' Dispose of the object if possible If obj IsNot Nothing AndAlso...
0
by: ravindarjobs | last post by:
dear friends, i am using ms access 2003. i wanted to export data from access table to excel table. so i have followed this Dim db As Database Dim ea As Excel.Application Dim rs As...
24
rauty
by: rauty | last post by:
Hi all, I'm trying to access the most recent instance of Excel so I can paste data. What works for me is if Excel isn't already opened, I open it and can paste the data where I want to. What...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.