无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的COM 对象强制转换为接口类型“Microsoft.Office.Interop.Excel._Application”

经测试,该方法同样适用于Word。

原文地址:http://hi.baidu.com/shijizhishang/item/ab70353315a9fafca984286f

如果您使用的电脑要操作的是Office 2003而之前使用过Office 2007使用此方法可解决您的问题

无法将类型为“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,并安装过Office 2007的兼容包,也安装过Office Visio 2007

解决办法:

在注册表中找到:

HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\1.6 删除之

就可以了。

因为我用的是Office 2003对应的是1.5,所以删除1.6

Office 2007对应的是1.6,所以要根据情况判断。

posted on 2013-12-03 19:40  XIN_001  阅读(36412)  评论(1编辑  收藏  举报