Is there a way to access a Ribbon (XML) at run time?

前端 未结 3 1149
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-06 06:18

I\'m working on a Word 2007 app-level add-in. So far, I haven\'t experienced major obstacles except for converting the add-in\'s Ribbon interface to XML. I have to use Ribbo

3条回答
  •  情歌与酒
    2020-12-06 06:45

    When working with Ribbon XML, I tried this but I couldn't access the Ribbon1 property from the Globals.Ribbons.. The property simple wasn't there..

    However, I came up with another solution which basically had to do with a proper type cast.

    In ThisAddIn.cs:

    private Microsoft.Office.Core.IRibbonExtensibility ribbonObj;
    protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
    {
     ribbonObj = new Ribbon1(this);
     return ribbonObj;
    }
    
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    { 
     // Calling the public method TEST() in Ribbon1.cs 
     //MyNameSpace is the namespace used in your project ie., your project name 
     ((MyNameSpace.Ribbon1)ribbonObj).TEST();
     // Calling the public variable flag in Ribbon1.cs  
     ((MyNameSpace.Ribbon1)ribbonObj).flag;
    }
    

提交回复
热议问题