473,320 Members | 1,707 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,320 software developers and data experts.

How to force ExcellApp.Quit() when it's actually called?

Hi,

I load the contents of an excel sheet into a dataset via the excel
object library (couldn't get the #$%#$^ oledb/ado route to work -
#^$%&^%$ connection strings... grrr.... )

Anyway, after I get the sheet's contents into my dataset, I'd love to
jettison excel. Calling ExcelApp.Quit() has no effect until I exit the
entire application. How can I force excelapp.quit() to take effect when
the line is executed?

thanks!

cdj

Oct 26 '06 #1
4 2162
Hi cdj,

Are you operating Excel through Late Binding?

I had similar issues to the ones you describe and found that Marshall.ReleaseComObject did the trick.

Hope it helps

Stuart King
Informology Ltd.

"sherifffruitfly" <sh*************@gmail.comwrote in message news:11**********************@m73g2000cwd.googlegr oups.com...
Hi,

I load the contents of an excel sheet into a dataset via the excel
object library (couldn't get the #$%#$^ oledb/ado route to work -
#^$%&^%$ connection strings... grrr.... )

Anyway, after I get the sheet's contents into my dataset, I'd love to
jettison excel. Calling ExcelApp.Quit() has no effect until I exit the
entire application. How can I force excelapp.quit() to take effect when
the line is executed?

thanks!

cdj
Oct 26 '06 #2

Stuart King wrote:
Hi cdj,

Are you operating Excel through Late Binding?
Hi Stuart -

Thanks for the reply.

My project's references to the Excel 11.0 object library are added
before I compile - I take it that's a "no" to your question?

Oct 26 '06 #3
Hi cdj,

I've tried the approach I gave you using the Microsoft Office
references(Early Binding) and in fact it still gives the desired effect. I
tried it out in a button click handler on a form. The following code does
nothing fancy, all it does is show Excel, waits for 5 seconds then quits
Excel again. If you use Task Manager you should be able to see the excel
process coming alve and then being unloaded from memory

private void button1_Click(object sender, EventArgs e)

{

Microsoft.Office.Interop.Excel.ApplicationClass App = new
Microsoft.Office.Interop.Excel.ApplicationClass();

App.Visible = true;

System.Threading.Thread.Sleep(5000);

App.Quit();

System.Runtime.InteropServices.Marshal.ReleaseComO bject(App);

}

Hope this helps.

Stuart King

Informology Ltd.

"sherifffruitfly" <sh*************@gmail.comwrote in message
news:11**********************@f16g2000cwb.googlegr oups.com...
>
Stuart King wrote:
>Hi cdj,

Are you operating Excel through Late Binding?

Hi Stuart -

Thanks for the reply.

My project's references to the Excel 11.0 object library are added
before I compile - I take it that's a "no" to your question?

Oct 27 '06 #4

Stuart King wrote:
System.Runtime.InteropServices.Marshal.ReleaseComO bject(App);
That line (which I didn't understand the first time you mentioned it)
solved all problems.

Thanks a million!

cdj

Oct 31 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: Curious Angel | last post by:
I have a resume in PDF format and I want anyone who LEFT-OR-RIGHT clicks the link to force the file to be saved, and in any event _not_ opened. Since the PDF will be in his cache in any event, I...
4
by: Lauren Quantrell | last post by:
If an Access2K ade is running, say it's named app1.ade, and I open app2.ade, I want app2.ade to determine if app1.ade is running, and if it is, I want app2.ade to close app1.ade. Is this easy? lq
0
by: lauren quantrell | last post by:
In Access, is there a simple way to determine if another Access application is running and then force it to quit? Example App1 is running. It checks to see if App2 is running. If App2 is...
1
by: palouf | last post by:
Hi everybody. I try to build some Outlook 2000 / XP Addin, It works fine with the XP version, but with OL 2k, nothing to do, it never quits outlook (i can see it in the process list) I read in a...
6
by: Max | last post by:
I have the following code on a form that launches Microsoft Outlook and creates a new email message for the user: Outlook.Application oApp = new Outlook.Application(); Outlook.MailItem oMail...
8
by: Keith H | last post by:
I'm looking for a way to force the user to re-authenticate with their Windows username/password/domain after clicking the submit button on an ASP.NET page. This is for an internal application. ...
2
by: Alan T | last post by:
private Interop.Word.Application _wordApp; What is the differences betwenn _wordApp.Quit(...) and _wordApp.Application.Quit(...) ?
3
by: Andy_Khosravi | last post by:
I have a method in place in my application to force users out. It's a simple tactic I got from these newsgroups where you create a table with one record called logout, then check that field with a...
2
by: tovishal2001 | last post by:
Hi, I am trying to read first 6000 bytes from a webpage, using StreamReader.Read(buffer, offset, no_of_bytes_to_read) method and trying to close the connection. Because, the useful data I need is...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.