Reputation: 1279
I have written a VSTO Excel application and I am trying to change the button behavior based on the sheets selected. The event is actually Raised in ThisWorkbook.cs
class and the Ribbon buttons are only accessible in Ribbon.cs class.
Is there any way to enable or disable the ribbon button from ThisWorkbook.cs class without creating the instance of ribbon in ThisWorkbook.cs
class?
void ThisWorkbook_SheetActivate(object Sh)
{
if (SomeCondition)
{
//Enable button
}
else
{
//Disable button
}
}
Upvotes: 1
Views: 1825
Reputation: 6742
You can access the ribbon via Ribbon ribon = Globals.Ribbons.Ribbon;
Upvotes: 6