How to intercept clicking of a built-in Office Ribbon control

后端 未结 1 2018
抹茶落季
抹茶落季 2021-01-21 08:39

I\'m wondering if it\'s possible to detect when a user has clicked the Header/Footer button in Excel so I can show some custom header/footer related ribbon controls on my add-in

1条回答
  •  耶瑟儿~
    2021-01-21 09:10

    One way I've discovered that worked was to use the section in the Ribbon XML (which I didn't know existed.) Apparently this mechanism allows you to re-purpose actions intrinsic to Excel but beware that not all controls support re-purposing the onAction callback)

    
    
        
            
        
      
        ...
    

    along with the associated event handler:

        public void testHeaderFooter(Office.IRibbonControl control, bool cancelDefault)
        {
            MessageBox.Show("Testing.");
            cancelDefault = false;
        }
    

    This link was very helpful:

    http://social.msdn.microsoft.com/Forums/office/en-US/e1a60d16-053e-4697-b17c-b22d602f0400/intercept-the-onaction-event-of-a-gallery-element-of-excel-2007-ui-ribbon?forum=vsto

    0 讨论(0)
提交回复
热议问题