打开 Excel 2016 文件失败,HRESULT:0x800706BE [英] Open Excel 2016 file failed with HRESULT: 0x800706BE

查看:24
本文介绍了打开 Excel 2016 文件失败,HRESULT:0x800706BE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用于打开现有 Excel 文件的简单 VB.NET 代码在打开命令时始终失败,并出现以下错误:

The simple VB.NET code for opening up an existing Excel file consistently failed at open command with the following error:

远程过程调用失败.(来自 HRESULT 的异常:0x800706BE)

The remote procedure call failed. (Exception from HRESULT: 0x800706BE)

我已经在 Stack Overflow 和 Microsoft 网站上搜索过此错误,但似乎没有人有明确的答案.但是在 64 位 Excel 中似乎总是发生一件事.

I've searched Stack Overflow and Microsoft sites for this error, it looks like no one has a definitive answer. But one thing consistent seems to be all happens with 64bit Excel.

无论如何,我在这里寻求帮助解决这个问题.下面是我非常简单的代码:

Anyway, I am here asking for help with this problem. Below is my very simple code:

Imports Microsoft.Office.Interop.Excel
Dim XLApp As Application = New Application()
Dim XLWkb as Workbook = XLApp.Workbooks.Open("TestExcel.xlsx")
Dim XLSht as WorkSheet = XLWkb.Sheet(1)
XLWkb.Close()
XLApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(XLSht)
System.Runtime.InteropServices.Marshal.ReleaseComObject(XLWkb)
System.Runtime.InteropServices.Marshal.ReleaseComObject(XLApp)

上面的代码在 XLApp.Workbooks.Open 行不断失败,并带有可怕的消息.

The above code kept failing at the XLApp.Workbooks.Open line with that dreadful message.

My windows is Windows 7 Enterprise Service Pack 1, 64-bit
My Excel is 2016 MSO (16.0.6701.1041) 64-bit version.
My MS Office is MS Office 365 ProPlus -en US (2016 version)
My VS is Visual Studio Community 2015 Version 14.0.24720.00 Update 1
Visual Basic 2015 00322-20000-00000-AA181
My project has the following references:

   Microsoft.Office.Core: Microsoft Office 16.0 Object Library
   Microsoft.Office.Interop.Excel : Microsoft Excel 16.0 Object Library
   VBIDE : Microsoft Visual Basic for Applications Extensibility 5.3

此外,我尝试将 Excel 文件放在我的 C:\Users 个人文件夹中,还尝试使用CreateObject("Excel.Application")"来创建 Excel 应用程序,所有在打开"调用时失败并显示相同的错误消息.

Also, I've tried putting the Excel file in my C:\Users personal folder, also tried to use 'CreateObject("Excel.Application")' to create the Excel application, all failed with the same error message upon 'Open' call.

好的,我也在不同的 Windows 7 Professional 64 位计算机上尝试了相同的程序,使用 MS Office 2007(因此,Microsoft Excel 12.0 对象库等)编译为 x86,它在打开"调用时也失败了.但还有另一个常见错误:HRESULT: 0x80010105 (RPC_E_SERVERFAULT),该错误已由许多其他开发人员发布.

Ok, I also tried this same program on a different Windows 7 Professional 64bit computer, with MS Office 2007 (hence, Microsoft Excel 12.0 Object library etc.), compiled to x86, it also failed at the 'Open' call. But with another common error: HRESULT: 0x80010105 (RPC_E_SERVERFAULT), which has been posted by many other developers.

然后,我在 Windows 8 机器上尝试了相同的程序,并使用 Office 2007 编译为 x86,并且运行良好.

Then, I tried this same program on a Windows 8 machine and compile to x86 with Office 2007 and it worked just fine.

所以,在这一点上,我认为这是 Microsoft.Office.Interop.Excel 的 Microsoft Windows 7 错误;所以,我放弃了进一步尝试,转而使用 7 以外的 Windows 版本进行开发.

So, at this point, I think this is a Microsoft Windows 7 bug with the Microsoft.Office.Interop.Excel; so, I am giving up on trying further and switch to dev on Windows version other than 7.

任何见解将不胜感激.

推荐答案

在 Excel 应用程序上调用 'Open' 方法时解决此异常的解决方案是将 Excel 应用程序设置为可见:

The solution to resolve this exception upon calling the 'Open' method on the Excel application is to set Excel application to be visible:

Dim XLApp As Application = New Application()
XLApp.Visible = True

不要问我为什么,因为我不知道,任何可以启发我的人,请这样做.

Don't ask me why, because I don't know, anybody who can enlighten me, please do so.

这篇关于打开 Excel 2016 文件失败,HRESULT:0x800706BE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆