我有一个看起来像这样的自定义功能区:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<backstage>
<tab id="CustomTab" insertBeforeMso="TabInfo" title="CustomTab" label="CustomTab">
<firstColumn>
<group id="openGroup">
<topItems>
<button id="btnOpen" label="Search" onAction="OpenForm" />
<button id="btnSave" label="Save" onAction="SaveForm" />
<button id="btnSaveAs" label="Save As" onAction="SaveAsForm" />
</topItems>
</group>
</firstColumn>
</tab>
<button idMso="FileSave" visible="false"/>
<tab idMso="TabRecent" visible="false" />
<tab idMso="TabSave" visible="false" />
<tab idMso="TabShare" visible="false"/>
</backstage>
</customUI>
虽然这在隐藏内置选项卡方面效果很好,但它不会隐藏快速访问工具栏中的“保存”按钮。
我查看了 Office 帮助文件,据推测 FileSave
是“保存”按钮的 ID,但它并没有隐藏它。我还尝试使用 Undo
,它应该从快速访问工具栏中隐藏“撤消”按钮,但这也不起作用。
是否可以通过编程方式或通过自定义功能区隐藏快速访问工具栏中的元素?我的目标是 Word、Excel 和 PowerPoint 2013 和 2016
最佳答案
您需要在 XML 中使用子元素 qat 和 documentControls/sharedControls。
并根据this你只能从头开始删除 qat。这意味着您必须定义要显示的所有元素!说实话不太舒服
<ribbon startFromScratch="true">
<qat>
<sharedControls>
<button idMso="FileSave" visible="true" />
<button idMso="Cut" visible="true" />
<button idMso="Copy" visible="true" />
<button idMso="Paste" visible="true" />
<button idMso="FileOpen" visible="true" />
</sharedControls>
</qat>
[..define other parts you want to show, tabs etc...]
</ribbon>
关于c# - 如何隐藏快速访问工具栏中的按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49799350/