简体   繁体   English

Excel 加载项的自定义功能区选项卡不会显示

[英]Excel Add In's Custom Ribbon Tab Will Not Display

I've created an application level add-in for Excel to automate some tasks.我为 Excel 创建了一个应用程序级加载项来自动执行某些任务。 I used the VS2012 template Visual C# > Office > 2010 > Excel 2010 Add-In.我使用了 VS2012 模板 Visual C# > Office > 2010 > Excel 2010 Add-In。

Rather than having an action pane open every time Excel does, I've opted to create a custom ribbon tab following these instructions:我没有每次 Excel 都打开操作窗格,而是选择按照以下说明创建自定义功能区选项卡:

http://msdn.microsoft.com/en-us/library/vstudio/bb386104.aspx http://msdn.microsoft.com/en-us/library/vstudio/bb386104.aspx

However, when I build my project, the tab does not display.但是,当我构建我的项目时,该选项卡不会显示。 I have verified the add-in is loading, and all of its features function properly, except the Ribbon.我已经验证加载项正在加载,并且除了功能区之外,它的所有功能都正常运行。 I created a simple form to test this, which loads as expected.我创建了一个简单的表单来测试它,它按预期加载。

I then tried creating an Excel 2010 Workbook project.然后我尝试创建一个 Excel 2010 工作簿项目。 After adding the Ribbon (using the same steps as before) and building the project, it simply works;添加 Ribbon(使用与之前相同的步骤)并构建项目后,它就可以正常工作了; the ribbon tab appears as expected.功能区选项卡按预期显示。

I've tried overriding ThisAddIn.CreateRibbonExtensibilityObject() to return my ribbon object, created via Globals.Factory.GetRibbonFactory().CreateRibbonManager.我尝试覆盖 ThisAddIn.CreateRibbonExtensibilityObject() 以返回我的功能区对象,该对象是通过 Globals.Factory.GetRibbonFactory().CreateRibbonManager 创建的。 Again, no dice.再次,没有骰子。

I'm at a loss now.我现在不知所措。

I also had this problem, where my VSTO ribbon wasn't being displayed.我也遇到了这个问题,我的 VSTO 功能区没有显示出来。

Here's my solution, using Excel 2013 and VS2015.这是我的解决方案,使用 Excel 2013 和 VS2015。

What you need to do is:你需要做的是:

  • Open the Ribbon Designer window打开功能区设计器窗口
  • Select the RibbonTab object选择RibbonTab对象
  • In the "Properties" window, expand " ControlId " branch, and change the ControlIdType from " Office " to " Custom "在“属性”窗口中,展开“ ControlId ”分支,将ControlIdType从“ Office ”改为“ Custom

在此处输入图片说明

Ridiculous, hey ?可笑,嘿?

But, strangely, it works...但是,奇怪的是,它有效......

I had this happen with using the xml ribbon developer tool.我在使用 xml 功能区开发人员工具时发生了这种情况。 You have to add this code (or similar functionality into ThisAddIn.cs (or primary add in class)您必须将此代码(或类似功能添加到 ThisAddIn.cs (或主要添加类)

    protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
    {
      return new Ribbon1();
    }

经过RibbonGroup ,我发现RibbonGroupPosition属性必须是Default

默认选项卡的可见属性值为False ,将其设置为True

I switched back to Visual Studio 2017 Community edition and it worked for me.我切换回 Visual Studio 2017 社区版,它对我有用。

As an up-gradation process, I'd migrated my VSTO Add-Ins from VS 2017 to VS 2019. When I compiled my Add-Ins on VS 2019 Community Add-Ins worked well for MS Word and Outlook, but MS Excel was not showing the Add-In (Ribbon)作为升级过程,我将 VSTO 加载项从 VS 2017 迁移到 VS 2019。当我在 VS 2019 社区加载项上编译加载项时,MS Word 和 Outlook 运行良好,但 MS Excel 不是显示加载项(功能区)

Tried many suggestions but did not work.尝试了很多建议,但没有奏效。 After switching back to VS 2017 Community it started working well.切换回 VS 2017 社区后,它开始运行良好。

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

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