Click here to Skip to main content
15,894,539 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,
I have a application in which i have to insert data i type in my windows form into the excel sheet.But when I close my windows form,i get automatically directed to the excel sheet where the data gets inserted.How to avoid it?I dont want the excel sheet to open when i close my form.plz help
Thnx in adv...
Posted

1 solution

I think you are not closing the excel workbook and worksheet in code.
Try to close and dispose the objects that are created in your code. This will resolve your problem.
 
Share this answer
 
Comments
AC777 12-Aug-11 2:55am    
Thnx suresh...
See I have an exit button on my form and the code behind this button is like this..
Application.Exit();
Excell.Workbook WorkBook;
object BlankValue = System.Reflection.Missing.Value;
Excell.Application App;
App = new Excell.ApplicationClass();
WorkBook = App.Workbooks.Add(BlankValue);
WorkBook.Close(true,BlankValue,false);

So I am closing the workbook as you see above.What should be changed?
Suresh Suthar 12-Aug-11 3:01am    
In your code you are call Application.Exit() first then below code will not get executed... Just paste this code above Application.Exit().
AC777 12-Aug-11 4:43am    
i tried that too...didnt work..
AC777 12-Aug-11 6:09am    
hey i made some changes and it worked...Thanx a lot Suresh !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900