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

Closing Excel File

Hi , I recently have much pain working with excel application especially closing excel . I try several method but with no success i try to urge garbage collector to dispose excel application object, I tried to kill excel process but i find it difficult to figure out which is the right process to kill .It is out of question to kill all process on the server so i have to find out which is the proper one bit I can't retrieve the id of the process after new excel application is created.I don't open excel in open window state otherwise it will be easy to retrieve the process id but ......

So I'll be very grateful to any help , because it makes me crazy already.
Mar 17 '08 #1
2 3029
jhardman
3,406 Expert 2GB
what method are you using to create the file, and what methods have you tried to destroy it?

Jared
Mar 18 '08 #2
Actually I don't create file I have prepared pattern to write in it.The new process is created when i started new excel application.I already come with solution to kill process but I am not quite convinced that i have the right solution.

Dim i As Integer = 0

For i = 1 To xlWrkBook.Worksheets.Count
xlWrkSheet = xlWrkBook.Worksheets(i)
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWrkSheet)
xlWrkSheet = Nothing
Next
For i = 1 To xlApp.Workbooks.Count
xlWrkBook = xlApp.Workbooks(i)
xlWrkBook.Close(False)
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlWrkBook)
xlWrkBook = Nothing
Next

xlApp.Quit()
System.Threading.Thread.Sleep(4000)
System.Runtime.InteropServices.Marshal.ReleaseComO bject(xlApp)
xlApp = Nothing
System.Threading.Thread.CurrentThread.CurrentCultu re = oldCI

GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

this is the piece of code i tried to close excel , it have to work it is commonly use in my work but it doesn't work at me . I decided to write all process in hashtable and then start new excel application which generate EXCEL process
and after that i find the new process and take id of the process and when it is needed i kill it. Good but i am not quite sure how this will work on server.
Mar 19 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: federico | last post by:
When I close an excel application opened from a python program with .Close() methood , in tasks manager is still present 'excel.exe' process and if I open manually an excel applicaion I have a...
5
by: Peter yeshew | last post by:
Is it possible to forbid closing the form through the File- Close menu ? On my form i have a command button called CmdDeleteInvoice. When this command button is visible ,i want to forbid the user...
0
by: Winshent | last post by:
this code opens the workbook.. either protects or unprotects a sheet.. then saves.. so can write to it.. it unprotects then saves fine.. then writes to it no prob.. it resets the password...
2
by: Atley | last post by:
I have written an application that exports data from SQL to Excel. It all works perfectly except that if you open the Task Manager after running my application, there is an instance of Excel in...
0
by: Sania | last post by:
Hi, We have an application that create an excel object on the very beginning of the application: objExcel = New Excel.Application Then I am passing the excel reference to the one of forms...
7
by: rdemyan via AccessMonster.com | last post by:
I want to make sure that I'm closing an opened spreadsheet correctly. I've been having some locking up problems. The following code adds a dummy row to the spreadsheet to ensure that that the data...
0
by: Jono | last post by:
Hello, I've been getting this message when closing excel (not necessarily when closing the workbook by itself, but when closing Excel and the workbook at the same time): ...
2
by: Silgd1 | last post by:
Hi All.... I'm using python 2.4, Win XP Pro v.2002 sp3, and I use pyscripter 1.9.9.2 as my editor. I have written code to open an existing excel file and grab some data. The problem I am...
2
by: Ram Baran | last post by:
Hi, I am opening a excel file by the C# code and performing some operation and close it. it is working fine. I am facing problem, when any other excel file is already open, my file open along...
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: 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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: 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.