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

做~自己de王妃 提交于 2019-12-01 23:46:45

One way I've discovered that worked was to use the <commands> 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)

<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2006/01/customui">
    <commands>
        <command idMso="HeaderFooterInsert" onAction="testHeaderFooter"/>
    </commands>
  <ribbon>
    <tabs>...

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!