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

Excel Process still running

Hi there,

I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the workbook. What I'm noticing is that once I'm done working with the workbook and have freed all the object references to the excel application, I still have an 'Excel' process running (when I look under 'Processes' in the Windows Task List).

Is there something I'm not cleaning up properly? Suggestions are greatly appreciated.

Here's what I'm doing:
Dim exApplication As Excel.Application
Dim exWorkBook As Excel.Workbook
Dim exWorkSheet As Excel.Worksheet
Try
exApplication = New Excel.Application
exWorkBook = exApplication.Workbooks.Open(fiSource.FullName)
exWorkSheet = exWorkBook.Worksheets(SHEET_NAME)
Dim iCount As Integer = 0
For r As Integer = 2 To MAX_CARDS
Dim strName As String = exWorkSheet.Cells(r, 1).value
If (strName Is Nothing) Then
Exit For
Else
.. do some stuff to the worksheet...
End If
Next
exWorkBook.Save()
Catch ex As Exception
MsgBox("There was an error accessing the Excel spreadsheet:" + vbCrLf + ex.ToString, MsgBoxStyle.Exclamation, Me.Text)
Finally
exWorkSheet = Nothing
exWorkBook = Nothing
exApplication.Quit()
exApplication = Nothing
End Try

Nov 20 '05 #1
3 2216
You need to insert a exWorkBook.Close() statement before exWorkBook =
Nothing.

Mike Ober.
"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
Hi there,

I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the
workbook. What I'm noticing is that once I'm done working with the workbook
and have freed all the object references to the excel application, I still
have an 'Excel' process running (when I look under 'Processes' in the
Windows Task List).
Is there something I'm not cleaning up properly? Suggestions are greatly appreciated.
Here's what I'm doing:
Dim exApplication As Excel.Application
Dim exWorkBook As Excel.Workbook
Dim exWorkSheet As Excel.Worksheet
Try
exApplication = New Excel.Application
exWorkBook = exApplication.Workbooks.Open(fiSource.FullName) exWorkSheet = exWorkBook.Worksheets(SHEET_NAME)
Dim iCount As Integer = 0
For r As Integer = 2 To MAX_CARDS
Dim strName As String = exWorkSheet.Cells(r, 1).value If (strName Is Nothing) Then
Exit For
Else
.. do some stuff to the worksheet...
End If
Next
exWorkBook.Save()
Catch ex As Exception
MsgBox("There was an error accessing the Excel spreadsheet:" + vbCrLf + ex.ToString, MsgBoxStyle.Exclamation, Me.Text) Finally
exWorkSheet = Nothing
exWorkBook = Nothing
exApplication.Quit()
exApplication = Nothing
End Try

Nov 20 '05 #2
It also helps if you use the following to release your com objects
System.Runtime.InteropServices.Marshal.ReleaseComO bject(exApplication)

Use this to release all the com objects you used

"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
Hi there,

I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the
workbook. What I'm noticing is that once I'm done working with the workbook
and have freed all the object references to the excel application, I still
have an 'Excel' process running (when I look under 'Processes' in the
Windows Task List).
Is there something I'm not cleaning up properly? Suggestions are greatly appreciated.
Here's what I'm doing:
Dim exApplication As Excel.Application
Dim exWorkBook As Excel.Workbook
Dim exWorkSheet As Excel.Worksheet
Try
exApplication = New Excel.Application
exWorkBook = exApplication.Workbooks.Open(fiSource.FullName) exWorkSheet = exWorkBook.Worksheets(SHEET_NAME)
Dim iCount As Integer = 0
For r As Integer = 2 To MAX_CARDS
Dim strName As String = exWorkSheet.Cells(r, 1).value If (strName Is Nothing) Then
Exit For
Else
.. do some stuff to the worksheet...
End If
Next
exWorkBook.Save()
Catch ex As Exception
MsgBox("There was an error accessing the Excel spreadsheet:" + vbCrLf + ex.ToString, MsgBoxStyle.Exclamation, Me.Text) Finally
exWorkSheet = Nothing
exWorkBook = Nothing
exApplication.Quit()
exApplication = Nothing
End Try

Nov 20 '05 #3
Hi,

Dont forget to call GC.Collect.

System.Runtime.InteropServices.Marshal.ReleaseComO bject(exApplication)
GC.Collect()

Ken
-----------------------
"Steve Flitcroft" <as*******@hotmail.com> wrote in message
news:en**************@TK2MSFTNGP12.phx.gbl...
It also helps if you use the following to release your com objects
System.Runtime.InteropServices.Marshal.ReleaseComO bject(exApplication)

Use this to release all the com objects you used

"Mike Eaton" <Mi*******@discussions.microsoft.com> wrote in message
news:40**********************************@microsof t.com...
Hi there,

I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the
workbook. What I'm noticing is that once I'm done working with the workbook
and have freed all the object references to the excel application, I still
have an 'Excel' process running (when I look under 'Processes' in the
Windows Task List).
Is there something I'm not cleaning up properly? Suggestions are greatly appreciated.
Here's what I'm doing:
Dim exApplication As Excel.Application
Dim exWorkBook As Excel.Workbook
Dim exWorkSheet As Excel.Worksheet
Try
exApplication = New Excel.Application
exWorkBook = exApplication.Workbooks.Open(fiSource.FullName) exWorkSheet = exWorkBook.Worksheets(SHEET_NAME)
Dim iCount As Integer = 0
For r As Integer = 2 To MAX_CARDS
Dim strName As String = exWorkSheet.Cells(r, 1).value If (strName Is Nothing) Then
Exit For
Else
.. do some stuff to the worksheet...
End If
Next
exWorkBook.Save()
Catch ex As Exception
MsgBox("There was an error accessing the Excel spreadsheet:" + vbCrLf + ex.ToString, MsgBoxStyle.Exclamation, Me.Text) Finally
exWorkSheet = Nothing
exWorkBook = Nothing
exApplication.Quit()
exApplication = Nothing
End Try


Nov 20 '05 #4

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

Similar topics

8
by: mytfein | last post by:
Hi Everyone, Background: Another department intends to ftp a .txt file from the mainframe, for me to process. The objective is to write a vb script that would be scheduled to run daily to...
5
by: cnathaide | last post by:
I am trying to control an existing running process from C#. More specifically, I am trying to control an existing workbook that is open in memory. I use the following code using...
8
by: ChrisBowringGG | last post by:
When you use Application.Quit() on an Excel application, there can still be an instance of Excel running, as seen in Task Manager. You can try following the advice on MSDN: ...
4
by: Powerguy | last post by:
Hi all, I've spent countless hours trying to get this silly EXCEL process to close once I have used it. If anyone can help it would really REALLy be appreciated! Below is my code- Dim t As...
2
by: Powerguy | last post by:
Hi all, I am looking for a way to get the Process id (or a handle) of an EXCEL process created from within my code. For example when the following code is executed: Dim EXL As...
18
by: lgbjr | last post by:
Hi All, I have a VB.NET app that, among other things, writes data to Excel. I am having trouble getting the Excel process to terminate after I quit Excel. I found an article related to this...
16
by: LP | last post by:
Hello, I am trying to use .NET with Excel. I installed Office 2003 and selected ..NET programming suport option, so it installed all those PIA, as MS sugests. But I can not find a way to destroy...
2
by: easoftware | last post by:
I would like to be able to use VB 2003 .NET to check if Excel is running, and if it is, then do something with the active workbook. I can see if Excel is running: Private Sub GetAllExcelApps()...
5
by: mabond | last post by:
Hi recently read a posting and reply about Excel processs still running after the Appliction.Quit was called. Thought I might be able to use the same...
7
by: =?Utf-8?B?VGVycnkgSG9sbGFuZA==?= | last post by:
I have a vb.net app that opens an excel worksheet, reads data and then closes the sheet. Im noticing that the Excel process is still running after I have closed and disposed of my excel objects. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.