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

Close an app in C#

Hi all,

I want to close excel application from C#, this is the piece of code I am
trying

"System.Runtime.InteropServices.Marshal.ReleaseCom Object(excelApp);"

GC.Collect();

It ain't working ! Any ideas please !!

Thanks.


Jul 21 '05 #1
3 1308
Assuming that your variable excelApp is just a reference to an Excel
Application, all you have to do is call excelApp.Quit();

HTH, Jakob.
"Richie" wrote:
Hi all,

I want to close excel application from C#, this is the piece of code I am
trying

"System.Runtime.InteropServices.Marshal.ReleaseCom Object(excelApp);"

GC.Collect();

It ain't working ! Any ideas please !!

Thanks.


Jul 21 '05 #2
Hi Richie,

This is fine, but on viewing "Task List" the application tab shows
"Excel.exe" running. And if I run the program again the message
"Administrator is using the file, file will open in readonly mode" shows.

Any ideas ?

"Jakob Christensen" <jc*@REMOVEpension.dk> wrote in message
news:AF**********************************@microsof t.com...
Assuming that your variable excelApp is just a reference to an Excel
Application, all you have to do is call excelApp.Quit();

HTH, Jakob.
"Richie" wrote:
Hi all,

I want to close excel application from C#, this is the piece of code I am trying

"System.Runtime.InteropServices.Marshal.ReleaseCom Object(excelApp);"

GC.Collect();

It ain't working ! Any ideas please !!

Thanks.


Jul 21 '05 #3
It sounds like you may be holding a reference to some of the Excel COM
objects. Did you try calling ReleaseComObject until it returns 0 on all your
references before calling Quit()?

"Richie" wrote:
Hi Richie,

This is fine, but on viewing "Task List" the application tab shows
"Excel.exe" running. And if I run the program again the message
"Administrator is using the file, file will open in readonly mode" shows.

Any ideas ?

"Jakob Christensen" <jc*@REMOVEpension.dk> wrote in message
news:AF**********************************@microsof t.com...
Assuming that your variable excelApp is just a reference to an Excel
Application, all you have to do is call excelApp.Quit();

HTH, Jakob.
"Richie" wrote:
Hi all,

I want to close excel application from C#, this is the piece of code I am trying

"System.Runtime.InteropServices.Marshal.ReleaseCom Object(excelApp);"

GC.Collect();

It ain't working ! Any ideas please !!

Thanks.



Jul 21 '05 #4

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

Similar topics

3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
6
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the...
10
by: Shang Wenbin | last post by:
Hi, When I want to close the current window using window.close() in IE6.0, there will be a confirm box that: The web page you are viewing is trying to close the window. Do you want to close this...
19
by: Lauren Wilson | last post by:
A2K app: Question: is the flagged line (<<<) below necessary. If that line is needed, what effect does it have (if any) on the fact that the very same database is the linked back end db? ...
4
by: GrantS | last post by:
I am having a problem closing a popup window opened modally. When I try to close the window (when the user hits save button and the data has been processed), the Popup window opens as a full screen...
35
by: Eric Sabine | last post by:
In my Finally block, I was using cn.close (where cn is an ADO.NET connection object, SQLConnection to be exact) and then I came across the following in some microsoft code. If Not cn Is Nothing...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
7
by: Toccoa | last post by:
After considerable googling - I mean searching with Google(r) - I could not find javascript on a button or <a href=... to close a window in the latest versions of IE and FireFox. There seemed...
2
by: kurt sune | last post by:
Hello, I have a weird problem, I hope someone can explain this for me. I have a webpage using masterpage. In it I create a popup window using this code: Dim js As String = "<script...
6
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am looking for a java script to close a web form that I can attatch to a button click event. I am using vs2005, c#. Thanks -- Paul G Software engineer.
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...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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:
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.