c# - 通过代码自定义开箱即用的功能区
问题描述
我正在开发 Visio COM 加载项。我需要隐藏或禁用一些现有的开箱即用功能区项目(并用自定义功能替换它们)。我看到“导入/导出”功能区选项的选项,但在运行时没有找到解决方法。任何人都可以提供类 OR 方法来获取 OOTB 功能区并对其进行操作吗?
谢谢
解决方案
问题已解决:我使用以下代码加载了我的自定义菜单:
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
每当此事件发生时,都会加载自定义菜单。唯一的问题是菜单是在文档之前加载的,因此,您需要保存并重新打开文档才能看到自定义... ;)
推荐阅读
- swift - 如何在协议扩展中定义可以设置和获取的变量
- linux - 通过 bash 查找特定文件的数量
- c++ - 在唯一指针映射上打开 mp 循环
- python - AttributeError:模块'caffe2.python._import_c_extension'没有属性'get_cudnn_version'
- c# - 检查网站名称是否存在于 IIS 中不起作用
- python - 使用 Python 读取 CSV 文件的值
- model-view-controller - 如果没有小数,则显示不带小数的 SQL 小数类型
- visual-studio - 如何在 VS2017 中为 dotnet 核心 Web API 应用程序设置 docker 项目 (dcproj)
- c - 对格式说明符整数 (%d) 的理解
- bootstrap-4 - Bootstrap - 使用表格响应固定左侧列并且不固定单元格宽度(以像素为单位)?