close process excell

#region Kill EXCEL
        //As a safety check go through all processes and make
        //doubly sure excel is shutdown. Working with COM
        //have sometimes noticed that the EXL.Quit() call
        //doesn't always do the job
        private void killExcel()
        {
            try
            {
                Process[] ps = Process.GetProcesses();
                foreach (Process p in ps)
                {
                    if (p.ProcessName.ToLower().Equals("excel"))
                    {
                        p.Kill();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR " + ex.Message);
            }
        }
        #endregion

posted @ 2011-06-30 22:19  greencolor  阅读(169)  评论(0编辑  收藏  举报