利用Custom Ribbon XML 重写Office内置按钮

1.  创建Office Application level AddIn(eg. Powerpoint 2010 AddIn)

2. 添加Ribbon.xml



  
    
    
    
    
  
  

3. 添加Callback函数到Ribbon1.cs 中

        private bool repurposing = true;
        // disable the command
        public bool rxshared_setDisabled(IRibbonControl control)
        {
            return false;
        }
        // repurpose the command
        public void rxFileSave_repurpose(IRibbonControl control, bool cancelDefault)
        {
            if (repurposing)
            {
                MessageBox.Show("The Save button has been temporarily repurposed.");
                cancelDefault = false;
            }
            else
            {
                cancelDefault = false;
            }
        }

运行效果


你可能感兴趣的:(RibbonX)