Hello Zino,
You are using the VB.NET, right?
Please refer this KB article to resolve the issue.
317109 Office application does not quit after automation from Visual Studio
..NET client
http://support.microsoft.com/default.aspx?scid=kb;EN-US;317109
When Visual Studio .NET calls a COM object from managed code, it
automatically creates a Runtime Callable Wrapper (RCW). The RCW marshals
calls between the .NET application and the COM object. The RCW keeps a
reference count on the COM object. Therefore, if all references have not
been released on the RCW, the COM object does not quit.
So you need to use the following code:
Private Sub NAR(ByVal o As Object)
Try
System.Runtime.InteropServices.Marshal.ReleaseComObject(o)
Catch
Finally
o = Nothing
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim oApp As New Excel.Application()
Dim oBooks As Excel.Workbooks = oApp.Workbooks
Dim oBook As Excel.Workbook = oBooks.Add
Dim oSheet As Excel.Worksheet = oApp.ActiveSheet
NAR(oSheet)
oBook.Close(False)
NAR(oBook)
NAR(oBooks)
oApp.Quit()
NAR(oApp)
Debug.WriteLine("Sleeping...")
System.Threading.Thread.Sleep(5000)
Debug.WriteLine("End Excel")
End Sub
Hope this helps.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.