Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Excel built-in RibbonButton?

Is it possible to set an excel 2010 built in RibbonButton to enabled=false from an excel VSTO Add-In?

I tried the following:

CommandBarControls controlls=Globals.ThisAddIn.Application.CommandBars.FindControls(MsoControlType.msoControlButton, 7374, null, false);
/// 7374 is the office control id of the control I want to access

foreach (CommandBarControl control in controlls)
{
    control.Enabled = false;
}

But this seems to work only for the right click context menu. And not for the ribbon buttons.

like image 452
flosk8 Avatar asked Jan 19 '26 07:01

flosk8


1 Answers

You can only disable tabs, not controls unless you use the startFromScratch Ribbon UI attribute. See MSDN for reference.

Also see Ribbon XML FAQ for good resources on Excel Ribbon manipulation.

like image 181
SliverNinja - MSFT Avatar answered Jan 21 '26 20:01

SliverNinja - MSFT