MANOJ GOPI
MANOJ GOPI

Reputation: 1279

Enable/Disable Ribbon button based on Excel Sheet Change - VSTO

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

Answers (1)

Malick
Malick

Reputation: 6742

You can access the ribbon via Ribbon ribon = Globals.Ribbons.Ribbon;

Upvotes: 6

Related Questions