Вы можете показать / скрыть ленты по имени с помощью следующего XML / C #.Я использовал настройку для хранения значения видимости.
![setting](https://i.stack.imgur.com/AVSbT.png)
Видео
![gif](https://i.stack.imgur.com/Um8XL.gif)
XML
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab idMso="TabHome" getVisible="GetVisible" />
<tab idMso="TabInsert" getVisible="GetVisible" />
<tab idMso="TabReview" getVisible="GetVisible" />
<tab idMso="TabData" getVisible="GetVisible" />
<tab idMso="TabView" getVisible="GetVisible" />
<tab idMso="TabFormulas" getVisible="GetVisible" />
<tab idMso="TabPageLayoutExcel" getVisible="GetVisible" />
<tab idMso="TabDeveloper" getVisible="GetVisible" />
<tab idMso="TabPrintPreview" getVisible="GetVisible" />
<tab idMso="TabAddIns" getVisible="GetVisible" />
<tab idMso="TabSetTableToolsExcel" getVisible="GetVisible" />
<tab
id="tabExample"
label="Example"
insertAfterMso="TabHome"
keytip="EX"
>
<group
id="grpRibbonVisibility"
label="Ribbon Visibility"
imageMso="WatchWindow"
>
<toggleButton
id="tglShowHideRibbons"
label="Show Hide Ribbons"
getPressed="GetPressed"
onAction="OnAction_Boolean"
imageMso="WatchWindow"
size="large"
screentip="Show or Hide Ribbons"
supertip="This will show or hide the system ribbons."
keytip="SHR"
/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
C #
/// <summary>
/// Assigns the visiblity to controls
/// </summary>
/// <param name="control">Represents the object passed into the callback procedure of a control in a ribbon or another user interface that can be customized by using Office Fluent ribbon extensibility. </param>
/// <returns>A method that returns true or false if the control is visible </returns>
public bool GetVisible(Office.IRibbonControl control)
{
try
{
switch (control.Id)
{
case "TabHome":
case "TabInsert":
case "TabReview":
case "TabData":
case "TabView":
case "TabFormulas":
case "TabPageLayoutExcel":
case "TabDeveloper":
case "TabPrintPreview":
case "TabAddIns":
case "TabSetTableToolsExcel":
return Properties.Settings.Default.IsRibbonVisible;
default:
return false;
}
}
catch (Exception ex)
{
//ErrorHandler.DisplayMessage(ex);
return false;
}
}
/// <summary>
/// Used for boolean controls like checkboxes and toggle buttons
/// </summary>
/// <param name="control"></param>
/// <param name="pressed"></param>
public void OnAction_Boolean(Office.IRibbonControl control, bool pressed)
{
try
{
switch (control.Id)
{
case "tglShowHideRibbons":
Properties.Settings.Default.IsRibbonVisible = pressed;
break;
}
ribbon.Invalidate();
}
catch (Exception)
{
//ErrorHandler.DisplayMessage(ex);
}
}
/// <summary>
/// To return the current value for boolean controls
/// </summary>
/// <param name="control"></param>
/// <returns></returns>
public bool GetPressed(Office.IRibbonControl control)
{
try
{
switch (control.Id)
{
case "tglShowHideRibbons":
return Properties.Settings.Default.IsRibbonVisible;
default:
return true;
}
}
catch (Exception)
{
//ErrorHandler.DisplayMessage(ex);
return true;
}
}
/// <summary>
/// Used to update/reset the ribbon values
/// </summary>
public void InvalidateRibbon()
{
ribbon.Invalidate();
}