简体   繁体   English

在Office 2007中部署VSTO 2010外接程序

[英]Deploying a VSTO 2010 Addin in Office 2007

I have an Excel 2010 VSTO addin developed using VS 2010. It's a RibbonUI based addin which adds a new tab to the Excel ribbon. 我有一个使用VS 2010开发的Excel 2010 VSTO加载项。这是一个基于RibbonUI的加载项,它向Excel功能区添加了一个新选项卡。 Now I have come across a situation where I need to deploy this addin for PCs running Excel 2007. 现在,我遇到了需要为运行Excel 2007的PC部署此插件的情况。

Under Properties -> Publish -> Prerequisites I have: 在“属性”->“发布”->“前提条件”下,我具有:

  • Microsoft .NET Framework 4 Client Profile (x84 and x64) Microsoft .NET Framework 4客户端配置文件(x84和x64)
  • Microsoft Office 2007 Primary Interop Assemblies Microsoft Office 2007主互操作程序集
  • Microsoft Visual Studio 2010 Tools for Office Runtime (x84 and x64) 用于Office Runtime的Microsoft Visual Studio 2010工具(x84和x64)
  • Windows Installer 3.1 Windows Installer 3.1

I managed to install the addin using the built-in publishing feature of VS 2010, by first installing the VSTO 2010 Runtime found here . 通过首先安装在此处找到的VSTO 2010 Runtime,我设法使用VS 2010的内置发布功能安装了插件。 The addin is then listed as an 'active' addin under 'Excel Options -> Addins' but the ribbon tab does not load in Excel 2007. I have enabled VSTO logging and alerts as described here , but no exceptions are reported there either. 然后,该加载项在“ Excel选项->加载项”下被列为“活动”加载项,但功能区选项卡未在Excel 2007中加载。我已按此处所述启用了VSTO日志记录和警报,但也未报告任何异常。

This might be a stupid question, but is there a way to get an Office 2010 addin to work in Office 2007? 这可能是一个愚蠢的问题,但是有没有办法让Office 2010插件在Office 2007中正常工作? (I found this question on SO, but it is not quite what I want to do) (我在SO上发现了这个问题,但这并不是我想要做的)

I know this was asked in mid-2013, but I've just started creating Office 2007 and 2010 add-ins, and have encountered the same issue. 我知道这是在2013年年中提出的,但是我刚刚开始创建Office 2007和2010加载项,并且遇到了相同的问题。

From Visual Studio, open the ribbon.xml file in your project. 在Visual Studio中,打开项目中的ribbon.xml文件。

Change the following line from 将以下行从

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">

to

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">

Notice the change from 2009/07 to 2006/01 . 注意从2009/072006/01的更改。 Office 2007 uses an older XML namespace schema compared to Office 2010. 与Office 2010相比,Office 2007使用较旧的XML名称空间架构。

Save the file and rebuild your project. 保存文件并重建您的项目。 Assuming your XML ribbon file is correct, the ribbon add-in should appear in the target application. 假设您的XML功能区文件正确,功能区加载项应出现在目标应用程序中。 An example of a ribbon XML file for Office 2007 and Office 2010 is below: 下面是Office 2007和Office 2010的功能区XML文件的示例:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="Ribbon_Load">
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns">
        <group id="GroupID" label="Example Group">
          <button id="button1" visible="true" size="large"
            label="Button 1" keytip="W"
            screentip="I display more information."
            onAction="The name of your method/function." imageMso="HyperlinkInsert"/>
        </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

Ensure the target machine has the following registry value 确保目标计算机具有以下注册表值

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Common\General\

Name = EnableLocalMachineVSTO
Value (DWORD) = 1

https://support.microsoft.com/en-us/kb/976811 https://support.microsoft.com/en-us/kb/976811

I have fixed this problem by adding my Registry keys to HKEY_CURRENT_USER. 我通过将注册表项添加到HKEY_CURRENT_USER来解决此问题。 Please check the following screenshot. 请检查以下屏幕截图。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM