.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Windows Application >> Post New QuestionBookmark and Share Subscribe to Forum

Close Excel File if any

Posted By: Suderson Sarathy     Posted Date: November 19, 2010    Points:2   Category :Windows Application
Hi All,

I want to close the alreadyu opened excel file if any, when the form loads.

Can anyone suggest me on this??

Responses
Author: Sadhuryan             
Posted Date: November 19, 2010     Points: 5   

Suderson Sarathy,


Simply call the "Quit()" function of the relevant Excel.Application object.

For example:
using Excel = Microsoft.Office.Interop.Excel;  

//this is required because there is otherwise an ambiguity between the Application" class under the Windows.Forms namespace and that of Excel
//if not you can simply say...


using Microsoft.Office.Interop.Excel;


//Then within your class you create an instance of the Excel.Application class

Excel.Application excel_app = new Excel.Application();

//Do whatever you want
.
.
.
.
.

excel_app.Quit();



Author: Suderson Sarathy             
Posted Date: November 21, 2010     Points: 5   

Hi.

You are opening a new file. Doing some operation and then closing it. Its working for me.
What am asking is, I want to check from the code that whether any Excel file is opening or not. If opened, I want to give the user a message like, please close all Excel app and proceed.

I want to check this in form load event. Can u understand my concept???



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend