Closing office apps with c#

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is probably something simple...
I'm trying to close a Powerpoint application from c# using:

PptApplication.Quit();
PptApplication = null;
GC.Collect();

I need all trace of the it to disappear immediatly, hence why I am calling
gabage collection, however it dosn't seem to disappear from the processes
list on task manager immediately (although if I wait around it does). Is
there a cleaner way to close powerpoint down?

Cheers
 
You can use GC.WaitForPendingFinalizers() to be sure all finalizers have
completed before moving on
You can also terminate the process
Process.GetProcessesByName("powerpnt.exe")[0].Close() or .Kill() to stop the
process immediately
 
Back
Top