简体   繁体   English

如何将 Word 功能区选项卡从 2007/2010 迁移到 2013

[英]How to migrate Word ribbon tab from 2007/2010 to 2013

I distribute a Word template with a large VBA code base in it.我分发了一个带有大型 VBA 代码库的 Word 模板。 The template includes a menu, and for Word 2007/2010 users, a ribbon tab.该模板包括一个菜单,对于 Word 2007/2010 用户,还有一个功能区选项卡。 In Word 2013, everything still works fine via the menu, but the ribbon is not showing up.在 Word 2013 中,通过菜单一切仍然正常,但功能区没有显示。 I still code in VBA without using Visual Studio (and don't want to buy VSTO).我仍然在不使用 Visual Studio 的情况下使用 VBA 进行编码(并且不想购买 VSTO)。 So i'm trying to figure out how to update my ribbon code/xml or whatever it is I need to do to make my ribbon tab show up in 2013.所以我试图弄清楚如何更新我的功能区代码/xml 或我需要做的任何事情,以使我的功能区选项卡在 2013 年显示。

The ribbon is copied into a new document from the template when a user creates a new document based on the template.当用户基于模板创建新文档时,功能区会从模板复制到新文档中。 But something's going wrong with that process in Word 2013. Interestingly, if I open a document that was previously created from my template (in Word 2010), the ribbon displays and works fine.但是在 Word 2013 中该过程出了点问题。有趣的是,如果我打开以前从我的模板(在 Word 2010 中)创建的文档,功能区会显示并正常工作。 But if I create a new Word 2013 document from the template, the ribbon is not there.但是,如果我从模板创建一个新的 Word 2013 文档,则功能区不存在。

There must be something I need to do in my code to tell Word to display the ribbon in new documents based on my template, but I haven't been able to find that information.我必须在代码中执行某些操作,以告诉 Word 在基于我的模板的新文档中显示功能区,但我一直无法找到该信息。

I've always generated my ribbon using "Office Custom UI Editor," which is not available for Word 2013;我一直使用“Office 自定义 UI 编辑器”生成我的功能区,这在 Word 2013 中不可用; that tool "inserts" the xml into the template.该工具将 xml“插入”到模板中。 My ribbon XML starts with this:我的功能区 XML 从这个开始:

<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="SERibbon_Load">
    <ribbon startFromScratch="false">
        <tabs>

Anybody know how to make my ribbon tab work with Word 2013?有人知道如何使我的功能区选项卡与 Word 2013 一起使用吗?

Well, it turns out that there really isn't a problem with my ribbon or code.好吧,事实证明我的功能区或代码确实没有问题。 The installer code that installs the template installs both a ".dot" template (without a ribbon) for users with Word 2003 or earlier, and a ".dotm" template (with ribbon) for more recent versions of Word.安装模板的安装程序代码为使用 Word 2003 或更早版本的用户安装“.dot”模板(不带功能区),并为更新版本的 Word 安装“.dotm”模板(带功能区)。 It then sets up a shortcut to the template on the user's start menu.然后在用户的开始菜单上设置模板的快捷方式。

The installer code isn't recognizing that Word 2013 was installed, and is concluding that the user is using Word 2003, and thus creating a shortcut to the ribbon-free version of the template.安装程序代码无法识别 Word 2013 已安装,并得出结论认为用户正在使用 Word 2003,因此创建了模板的无功能区版本的快捷方式。 I changed the shortcut to point to the ".dotm" version, and all is well.我将快捷方式更改为指向“.dotm”版本,一切都很好。 So it turns out that my custom ribbon tab works fine in Word 2007/2010/2013.结果证明我的自定义功能区选项卡在 Word 2007/2010/2013 中运行良好。 I just had to fix my installer to detect Word 2013 (version "15" in the registry) is installed.我只需要修复我的安装程序以检测安装了 Word 2013(注册表中的版本“15”)。

The namespace apparently changed in 2010, but is backward compatible with 2007. 2010 added things to the namespace, 2013 added new things, but my understanding is that it's the same schema, and thus also backward compatible with Word 2007 ribbon definitions.命名空间在 2010 年显然发生了变化,但与 2007 向后兼容。2010 年向命名空间添加了内容,2013 年添加了新内容,但我的理解是它是相同的架构,因此也向后兼容 Word 2007 功能区定义。

G G

I haven't done this yet, myself, but check out this thread from msdn: http://social.msdn.microsoft.com/Forums/en-US/officegeneral/thread/6575cee8-796a-40da-9520-24c5161f7600 .我自己还没有这样做,但请从 msdn 中查看此线程: http://social.msdn.microsoft.com/Forums/en-US/officegeneral/thread/6575cee8-796a-40da-9520-24c5161f7600

It looks like the namespace is the same, but some attribute values may have changed.看起来命名空间是相同的,但某些属性值可能已更改。 You may have want to check against the documentation to see if your ribbonXML is in compliance: http://www.microsoft.com/en-us/download/details.aspx?id=727 .您可能需要检查文档以查看您的ribbonXML 是否符合要求: http : //www.microsoft.com/en-us/download/details.aspx?id= 727。

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

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