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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41562540/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 20:10:05  来源:igfitidea点击:

Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'

excelvb.net

提问by jafla nasif

I am getting an error:

我收到一个错误:

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 Query Interface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

无法将类型为“Microsoft.Office.Interop.Excel.ApplicationClass”的 COM 对象转换为接口类型“Microsoft.Office.Interop.Excel._Application”。此操作失败,因为 IID 为“{000208D5-0000-0000-C000-000000000046}”的接口的 COM 组件上的查询接口调用因以下错误而失败:加载类型库/DLL 时出错。(来自 HRESULT 的异常:0x80029C4A (TYPE_E_CANTLOADLIBRARY))。

When I am trying to open Excel application in VB.NET I tried to reinstall excel but didn't fix the problem.

当我尝试在 VB.NET 中打开 Excel 应用程序时,我尝试重新安装 excel 但没有解决问题。

回答by Bhupinder

My issue resolved, after deleting 1.9 registry key under Start--> Run --> regedit --> HKEY_CLASSES_ROOT-->TypeLib-->{00020813-0000-0000-C000-000000000046} --> 1.9

在开始--> 运行--> regedit --> HKEY_CLASSES_ROOT-->TypeLib-->{00020813-0000-0000-C000-000000000046}--> 1.9 下删除1.9 注册表项后,我的问题解决了

回答by Aliendo

I have the same problem, I searched for the solution for days . and today I found it, maybe can help you (I delete 1.9 and left 1.8)

我有同样的问题,我搜索了几天的解决方案。今天我找到了,也许可以帮助你(我删除了1.9并留下了1.8)



If this is not a code related error than please remove below given key from registry.

如果这不是与代码相关的错误,请从注册表中删除以下给定的键。

Steps:

脚步:

Start--> Run --> regedit --> HKEY_CLASSES_ROOT-->TypeLib-->{00020813-0000-0000-C000-000000000046} --> 1.8/1.7 (Delete this)

开始--> 运行--> regedit --> HKEY_CLASSES_ROOT-->TypeLib-->{00020813-0000-0000-C000-000000000046} --> 1.8/1.7(删除这个)

Solution: This issue can be resolved by deleting an invalid registry key left over from the higher version of Office. Follow the above steps.

解决方案:可以通过删除较高版本的 Office 遗留的无效注册表项来解决此问题。按照上述步骤操作。

Cause: This issue is caused by a left over registry key if you have downgraded your version of Microsoft Office from either Office 2010 to Office 2007, or Office 2013 to Office 2010 or 2007.

原因:如果您已将 Microsoft Office 版本从 Office 2010 降级到 Office 2007,或将 Office 2013 降级到 Office 2010 或 2007,则此问题是由遗留的注册表项引起的。

Let me know if this solution is not helped to you

如果此解决方案对您没有帮助,请告诉我



LINK

关联

unable to cast COM object of type 'microsoft.Office.Interop.Excel.ApplicationClass' to 'microsoft.Office.Interop.Excel.Application'"

无法将“microsoft.Office.Interop.Excel.ApplicationClass”类型的 COM 对象转换为“microsoft.Office.Interop.Excel.Application”

LINK

关联

回答by HackSlash

The error may say it can't load a DLL but if you are trying to load Excel that is where the problem is.

该错误可能表示无法加载 DLL,但如果您尝试加载 Excel,这就是问题所在。

For some people, doing a simple Office repair from Add\Remove programs: Modify is enough to fix the problem.

对于某些人来说,从添加\删除程序进行简单的 Office 修复:修改就足以解决问题。

If you have already tried an Office repair then you can fix it manually by editing the registry.

如果您已经尝试过 Office 修复,则可以通过编辑注册表手动修复它。

Open Regedit as admin and go to:

以管理员身份打开 Regedit 并转到:

Computer\HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}\

This is the location that shows where Excel is installed. At this point if you see multiple versions, "1.9", "1.8", "1.7" then you need to remove the extra entries. For example Excel 2019 is "1.9" so if you would remove lower versions no longer installed.

这是显示 Excel 安装位置的位置。此时,如果您看到多个版本,“1.9”、“1.8”、“1.7”,那么您需要删除额外的条目。例如,Excel 2019 是“1.9”,因此如果您要删除不再安装的较低版本。

Once you have only one version you also need to check the bitness. I had moved from 32-bit to 64-bit but both keys were still present

一旦您只有一个版本,您还需要检查位数。我已经从 32 位转移到 64 位,但两个键仍然存在

Computer\HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}.9##代码##\Win32
Computer\HKEY_CLASSES_ROOT\TypeLib\{00020813-0000-0000-C000-000000000046}.9##代码##\Win64

I removed the Win32 key and everything began working again. Inside these keys the default value shows the full path to "EXCEL.EXE". Ensure that path is correct.

我删除了 Win32 密钥,一切又开始工作了。在这些键中,默认值显示“EXCEL.EXE”的完整路径。确保路径正确。