Problems with excel.exe kill

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hello all good people,
Hoope you would help me with my problem. I have a lot automated excel by vb.net. But i got a big problem with one of my projects which is working with two workbooks. Anyway the EXCEL.EXE staying in taskmanager. This is my code i am using:
<pre class="prettyprint lang-vb" style="font-size:12px Imports Excel = Microsoft.Office.Interop.Excel

Module Main

Create Excel objects
Public objApp As New Excel.Application

Public WorkDirectory = "C:UsersuserDocumentsVisual Studio 2005ProjectsWorking with Excels"

Sub Main()
Try
With objApp

.Workbooks.Open(Filename:=Local & "MyMain.xls")
.Workbooks.Open(Filename:=Local & "Other.xls")
..........
..........
operations on two workbooks...
..........
..........

.Workbooks("Other.xls").Close(True)
.Workbooks("MyMain.xls").Close(True)

End With

Catch ex As Exception
Console.WriteLine("Error occurs: " & ex.ToString)
Finally

objApp.Quit()
NAR(objApp)
GC.Collect()
GC.WaitForPendingFinalizers()

End Try

End Sub

End Module

------------------------------------------

Module RealaseExcelObjects

Public Sub NAR(ByVal o As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
Catch
Finally
o = Nothing
End Try
End Sub

End Module
[/code]
Anyway after that i have still the EXCEL.EXE in processes.
I found out also this topic, mayby it could be helpfull in my case but i dont know how to implement it in my code:
http://social.msdn.microsoft.com/Forums/en-US/innovateonoffice/thread/65f9721f-e1a1-4757-8273-a77f526eee49?prof=required

Could you please help me, what to do?

View the full article
 
Back
Top