try { excel.Visible = false;//任意Excel操作 } catch (System.Runtime. Ex) { int ErrCd = Ex.ErrorCode; //此处可以获取COM连接的异常代码 0x800706BA //Ex.Source 为"Microsoft.Office.Interop.Excel" }