本文介绍了错误调用属性workbook.FileFormat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 鉴于我已从Internet下载了工作簿(.xlsx)。 我已经为Excel安装了我的VSTO加载项。 订阅事件"Application.WorkbookOpen"的加载项。 当我打开工作簿时。 然后通知弹出窗口"注意 - 来自Internet的文件......除非你需要编辑,否则保持受保护的视图更安全"。 当我允许编辑工作簿时。 然后事件处理程序"Application.WorkbookOpen"调用属性"Workbook.FileFormat", 它会抛出一个错误"System.Runtime.InteropServices.COMException(0x80020005):在Microsoft.Office.Interop.Excel中输入不匹配。(HRESULT异常:0x80020005(DISP_E_TYPEMISMATCH)) .WorkbookClass.get_FileFormat()"。 注意:如果我将Workbook对象用作动态,则"Workbook.FileFormat"将返回"-2146826246"。 为什么抛出这个异常?什么是"-2146826246"?有没有人遇到过类似的问题?解决方案 此论坛适用于 Azure Stack,一种混合​​云平台,允许您使用数据中心的Azure服务 。看起来您正在寻找来获取Azure Devops的帮助。 Azure Devops 主要支持 使用azure-devops标签的StackOverflow 。最好的办法是在那里发布你的问题以寻求帮助。  Given I have downloaded a workbook (.xlsx) from the Internet.And I have installed my VSTO add-in for Excel.And the add-in subscribed to event "Application.WorkbookOpen".When I open the workbook.Then notification pop-ups with "Be careful - files from the Internet... Unless you need to edit, it's safer to stay in Protected View".When I allow editing the workbook.Then handler of event "Application.WorkbookOpen" calls property "Workbook.FileFormat",And it throws an error "System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) in Microsoft.Office.Interop.Excel.WorkbookClass.get_FileFormat()".Note: If I use Workbook object as dynamic, then "Workbook.FileFormat" returns "-2146826246".Why did this exception throw? What is "-2146826246"? Has anyone encountered a similar problem? 解决方案 This forum is for Azure Stack, a Hybrid Cloud Platform that lets you use Azure services from your datacenter. It looks like you are looking for assistance with Azure Devops. Azure Devops is primarily supported in StackOverflow using the azure-devops tag. Your best bet is to post your question there for assistance.  这篇关于错误调用属性workbook.FileFormat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-20 14:16