473,480 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1309
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
9058
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
2723
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
37968
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
14011
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
34827
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
11331
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
9605
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
5787
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
6737
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
3227
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.
0
6908
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...
0
7043
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7081
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6737
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5336
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4776
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4481
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2984
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
179
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.