In certain contexts I want to hide the paste option from the right click menu. In my proof of concept I was able to remove all but the paste option. It seems it is a weird group of controls, which doesn't want to be enabled or made not visible.
Here my attempt:
var allBars = ExcelApp.CommandBars;
for (int k = 1 ; k < allBars.Count; k++)
{
//var cellBar = ExcelApp.CommandBars["Cell"];
if (cellBar.Name == "Cell" || true)
{
for (int i = 1; i <= cellBar.Controls.Count; i++)
{
var control = cellBar.Controls;
if (control.Id == 3125 || control.Id == 3624 || control.Id == 21437 || control.Id == 22)
{
control.Enabled = false;
control.Visible = false;
}
}
}
}
Here my attempt:
var allBars = ExcelApp.CommandBars;
for (int k = 1 ; k < allBars.Count; k++)
{
//var cellBar = ExcelApp.CommandBars["Cell"];
if (cellBar.Name == "Cell" || true)
{
for (int i = 1; i <= cellBar.Controls.Count; i++)
{
var control = cellBar.Controls;
if (control.Id == 3125 || control.Id == 3624 || control.Id == 21437 || control.Id == 22)
{
control.Enabled = false;
control.Visible = false;
}
}
}
}