首页 > 解决方案 > 通过代码自定义开箱即用的功能区

问题描述

我正在开发 Visio COM 加载项。我需要隐藏或禁用一些现有的开箱即用功能区项目(并用自定义功能替换它们)。我看到“导入/导出”功能区选项的选项,但在运行时没有找到解决方法。任何人都可以提供类 OR 方法来获取 OOT​​B 功能区并对其进行操作吗?

谢谢

标签: c#vstovisio

解决方案


问题已解决:我使用以下代码加载了我的自定义菜单:

internal void SetRibbonCustomUI()
{
    string customUI = = @"<customUI onLoad=""_MyRibbon.Load"" xmlns=""http://schemas.microsoft.com/office/2009/07/customui"">";
    customUI += @"<ribbon>";
    customUI += @"<tabs>";
    customUI += @"<tab idMso=""TabHome"">";
    customUI += @"<group idMso=""GroupEditing"" visible=""false""/>";
    customUI += @"</tab>";
    customUI += @"</tabs>";
    customUI += @"</ribbon>";
    customUI += @"</customUI>";

    this.Application.ActiveDocument.CustomUI = customUI;
}

该解决方案的关键问题是方法的使用:_MyRibbon.Load 每当此事件发生时,都会加载自定义菜单。唯一的问题是菜单是在文档之前加载的,因此,您需要保存并重新打开文档才能看到自定义... ;)


推荐阅读