0

I am following article https://learn.microsoft.com/en-us/office/dev/add-ins/develop/add-in-manifests?tabs=tabid-1 and https://learn.microsoft.com/en-us/office/dev/add-ins/design/disable-add-in-commands . The method Office.onReady is active when task pane is opened . I want to call method on background to enable/disable add-ins tabs . Is any Office API and Graph API available for it ?.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

1 Answers1

0

The requestUpdate method is used to toggle the enabled or disabled status of a custom button on either a custom contextual tab or a custom core tab. For details about this, see Enable and Disable Add-in Commands. There may be scenarios in which you want to change both the visibility of a tab and the enabled status of a button at the same time. You do this with a single call of requestUpdate. The following is an example in which a button on a core tab is enabled at the same time as a contextual tab is made visible.

function myContextChanges() {
    Office.ribbon.requestUpdate({
        tabs: [
            {
                id: "CtxTab1",
                visible: true
            },
            {
                id: "OfficeAppTab1",
                groups: [
                    {
                        id: "CustomGroup111",
                        controls: [
                            {
                                id: "MyButton",
                                enabled: true
                            }
                        ]
                    }
                ]
            ]}
        ]
    });
}

Be aware, custom contextual tabs are currently only supported on Excel and only on these platforms and builds:

  • Excel on Windows (Microsoft 365 subscription only): Version 2102 (Build 13801.20294) or later.
  • Excel on Mac: Version 16.53.806.0 or later.
  • Excel on the web

Read more about that in the Create custom contextual tabs in Office Add-ins article.

If you need to get the same functionality in other Office applications, I'd suggest posting or voting for feature requests on Tech Community, they are considered when the dev team go through the planning process. Use the github label: Type: product feature request at https://aka.ms/M365dev-suggestions .

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • Hi @eugene myContextChanges is called from my code . I need event after Ribbon loaded into documents . Like I can enable/disable add-ins base on document name . Thanks Prithavi – Prithavi raj Oct 06 '22 at 14:29
  • You can check out the document name and then call `requestUpdate` method to update the ribbon UI. – Eugene Astafiev Oct 06 '22 at 22:23
  • Method requestUpdate is calling from our code when Office API is loaded, but it calling on click of custom add-ins tabs. I don’t want to click on any tab while I need event within my code to execute when Ribbon loads into document. – Prithavi raj Oct 07 '22 at 05:40