How to kill excel process kill....

Hi

I want to kill the excel process when it go's to exception handling, because when i get exception for some reason it returns back to my application, but the excel is still running in process.
AdnanAsked:
Who is Participating?
 
AdnanConnect With a Mentor Author Commented:
i fixed it ;)

 ArrayList listExcelProcIDs = new ArrayList();
foreach (System.Diagnostics.Process proc in System.Diagnostics.Process.GetProcessesByName("EXCEL"))
                {
                    if (!listExcelProcIDs.Contains(proc.Id))
                        proc.Kill();
                }
0
 
AdnanAuthor Commented:
another solution here: ;)*

Process[] process = Process.GetProcessesByName("Excel");
                for (int i = 0; i < process.GetLength(0); i++)
                {
                    //kills excel process
                    process[i].Kill();
                }    
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.