Close a running application

  • Thread starter Thread starter Amjad
  • Start date Start date
A

Amjad

I have a program that updates an Excel sheet everytime
the user presses a button. However, each time it creates
a new instance of the Excel.exe application running in
the background.
I tried closing my Excel object (oExcel) using the
following:
oExcel = Nothing
oExcel.quit()

Yet, I still can see an instance of Excel.exe in the
Windows Task Manager Processes.

Any idea on how to force this application to terminate
once I'm done with it?

Note1: I define the Excel object using:

Dim oExcel As Excel.Application
oExcel = CType(CreateObject("Excel.Application"), _
Excel.Application)

Note2: When I end my program, that instance of Excel
disappears. I wish to see that without leaving my program.
 
* "Amjad said:
I have a program that updates an Excel sheet everytime
the user presses a button. However, each time it creates
a new instance of the Excel.exe application running in
the background.
I tried closing my Excel object (oExcel) using the
following:
oExcel = Nothing
oExcel.quit()

Yet, I still can see an instance of Excel.exe in the
Windows Task Manager Processes.

Any idea on how to force this application to terminate
once I'm done with it?

Note1: I define the Excel object using:

Dim oExcel As Excel.Application
oExcel = CType(CreateObject("Excel.Application"), _
Excel.Application)

Note2: When I end my program, that instance of Excel
disappears. I wish to see that without leaving my program.

\\\
System.Runtime.InteropServices.Marshal.ReleaseComObject(App)
App = Nothing

' Perhaps you need these lines too:
GC.Collect()
GC.WaitForPendingFinalizers()
///
 
Hi..
Thanks for your reply, but the problem hasn't been solved
yet! (Excel.exe is still running in the background)
Any other suggestions?

Amjad
 
Hi Amjad,

You may have to do the same sort of releasing on <all> of the Excel
objects that you create.

Next year's .NET will include better Office integration. Perhaps they will
have addressed this issue.

In the meantime, the interop newsgroup is possibly the best place for this
question as they must have been asked it a hundred times for Excel and all the
other Office products.
news://msnews.microsoft.com/microsoft.public.dotnet.framework.interop

Regards,
Fergus
 
Back
Top