我们将 Excel 自定义作为 xlsm 文档后面的代码进行分发。以前,我们的构建服务器安装了 Office 2007,我们使用 Office 2007 主互操作程序集构建了 xlsm(并将它们添加为安装先决条件)。
最近,我们将构建服务器升级到 Office 2013,并开始使用 Microsoft Visual Studio 2010 Tools for Office Runtime 构建 xlsm(并将它们添加为安装先决条件)。
问题:以前保存对旧 xlsm 文件(使用 Office2007PIA 构建)的更改的用户一旦在他们的机器上安装了新版本的自定义,就无法打开他们的旧文件。他们得到以下异常:
************** Exception Text **************
System.Runtime.InteropServices.COMException (0x80070490): Element not found. (Exception from HRESULT: 0x80070490)
at Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IHostItemProvider.GetHostExtender(String extenderType, String extenderCookie, IntPtr& extenderObject)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.Office.Tools.IHostItemProvider.GetHostExtender(Type primaryType, String primaryCookie)
at Microsoft.Office.Tools.Excel.ControlSiteImpl..ctor(IServiceProvider serviceProvider, IHostItemProvider hostItemProvider, String primaryCookie, String identifier, Object containerComponent, UInt32 officeVersion, Control control, _OLEObject extenderControl, Boolean isDynamic)
at Microsoft.Office.Tools.Excel.FactoryImpl.Microsoft.Office.Tools.Excel.Factory.CreateControlSite(IServiceProvider serviceProvider, IHostItemProvider hostItemProvider, String primaryCookie, String identifier, Object containerComponent, Control control)
at Microsoft.Office.Tools.Excel.Controls.Label..ctor(Factory factory, IHostItemProvider hostItemProvider, IServiceProvider serviceProvider, String cookie, String extenderCookie, Object container, String identifier)
at MyCustomization.Sheet1.InitializeControls()
at MyCustomization.Sheet1.Initialize()
at Microsoft.Office.Tools.Excel.WorksheetBase.Microsoft.Office.Tools.EntryPoint.Initialize()
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases)
at Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.LoadEntryPoints(IntPtr serviceProvider)
问题:我们如何使新版本与使用旧版本保存的 xlsm 文件向后兼容?