C#與excel互操作的錯誤無法將類型為“Microsoft.Office.Interop.Excel.ApplicationClass”的 COM 對象強制 如果您使用的電腦要操作的是office2003而之前使用過office2007使用此方法可解決您的問題 無法將類型為“Microsoft.Office.Interop.Excel.ApplicationClass”的 COM 對象強制轉換為接口類型“Microsoft.Office.Interop.Excel._Application”。此操作失敗的原因是對 IID 為“{000208D5-0000-0000-C000-000000000046}”的接口的 COM 組件調用 QueryInterface 因以下錯誤而失敗: 庫沒有注冊。 (異常來自 HRESULT:0x8002801D (TYPE_E_LIBNOTREGISTERED))。英文版的異常消息如下: Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND)). 出現的原因可能是安裝office時安裝過不同版本造成的 本人安裝的是office 2003,並安裝過office2007的兼容包,也安裝過office visio 2007 解決辦法: 在注冊表中找到: ?HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\1.6 刪除之 就可以了。 因為我用的是office 2003對應的是1.5,所以刪除1.6 office 2007對應的是1.6,所以要根據情況判斷。