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

Excel Applications in C#

I am writing a C# program which creates an Excel Application and
inside of this applicaion, multiple workbooks. Here is my problem: I
need to be able to tell/determine if the Excel Application has been
closed by the user. If the excel application is closed, then I need
to recreate an Excel Application to continue adding workbooks to.

Does anyone have an idea or example code on how to determine if an
Excel Application has been closed or if it is still running?

Thanks in advance for any help!
Nov 16 '05 #1
2 1647
tyler --

I can think of a couple of things you might want to look at. For example,
there are several events that you can hook, if you are creating your Excel
Application in c#. For example:

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

myBook2 = myClass.Workbooks.Open(sExcelFile,x,x,x,x,x,x,x,x, x,x,x,x,x,x);

myClass.WorkbookBeforeClose += ...

The WordbookBeforeClose event will fire everytime a user clicks the close
button. You can add code to verify that there is still at least 1 workbook
open. Or you could prevent them from closing the workbook all together.

If you are more concerned about the Excel Application as a whole, you can
always check to see if (myClass == null), or, you can look at the
System.Diagnostics.Processes.GetProcessesByName method, and see if excel is
still running.

good luck, jason

"tyler" <sn*****@hotmail.com> wrote in message
news:69**************************@posting.google.c om...
I am writing a C# program which creates an Excel Application and
inside of this applicaion, multiple workbooks. Here is my problem: I
need to be able to tell/determine if the Excel Application has been
closed by the user. If the excel application is closed, then I need
to recreate an Excel Application to continue adding workbooks to.

Does anyone have an idea or example code on how to determine if an
Excel Application has been closed or if it is still running?

Thanks in advance for any help!

Nov 16 '05 #2
jason

thanks for the help. i will give that a try.

tyler
Nov 16 '05 #3

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

Similar topics

11
by: Mr. Smith | last post by:
Hello all, My code can successfully open, write to, format and save several worksheets in a workbook then save it by a given name, close and quit excel. My problem is that if I try and do it...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
3
by: mphanke | last post by:
Hi, I'm writting an application based on an SQL Server for Order Management. I have some data I want to export to Excel and Word, maybe some day I will implement a serial letter. The problem...
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...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
0
by: jason_cuteboy | last post by:
Hi all, Completely new to Vb.net and trying to create a simple VB Office Excel application/spreadsheet. When I built the project, and excel opens up an error comes up.... Customization assembly...
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
2
by: B.N.Prabhu | last post by:
In my web application(C#) . I am adding one excel sheet and then save and closing that excel file. In the finally bloack i gave Marshal.ReleaseComObject(clsExcel); But when i go and see in the...
8
by: Bruce_Stough | last post by:
I am currently using Control.DoDragDrop to drop a text string into Excel. I use the following code DataObject dd = new DataObject();...
1
by: Cristina | last post by:
Hi, i'm trying to launch excel from an asp.net application. My problem is that i already install excel 2003 on the server but i dont find excel on the list of dcom applications; do i need to do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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: 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...
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
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
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
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...

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.