locked
Ribbon buttons and context menus for Office 2007 , 2010 ,2013 and 2016 RRS feed

  • Question

  • Hello

    Need help and guidance for the office addins for MS Office versions 2007 , 2010 , 2013 and 2016

    What i have implemented and how:

    -VSTO addins 2013 for Outlook , Excel , PowerPoint and word. 

    -Project .net frame work is 4.5.2

    -Ribbon buttons and context menus using ribbon xml approch

    Above ribbon button and right click context menus are seeing and working fine for office applications 2010 , 2013 and  2016 But i am not able to see them in Office applications 2007.

    I am wondering why is it not seeing in 2007 ?

    I have given am search on it and found that the Office 2007 approach for Ribbon button and context menu is different from 2010-2016. is it?

    Please guide me for the below:

    1. Do i have to implement ribbon button and context menu for Office 2007 differently than Ribbon xml approch ?

    2. Can Ribbon button and context menus for Office 2007 and Office applications 2010-2016 can co-exist?

    Please provide , If any reference or implementation links for the same. It would be help.

    Any guidance will be helpful !

    Thnaks

    Wednesday, August 24, 2016 5:38 AM

Answers

  • Hi daxesh,

    In Excel 2007, you can add controls to almost every context menu with VBA code. However, it is not possible to change some context menus such as the Shapes and Picture context menu with VBA. In addition, it is not possible to change context menus with RibbonX. You could refer the link below for more information.

    #Customizing Context Menus in All Versions of Microsoft Excel
    https://msdn.microsoft.com/en-us/library/office/gg469862(v=office.14).aspx

    In VSTO project, you could try above way, a simple code like below:

           private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                this.Application.WorkbookActivate += Application_WorkbookActivate;
                this.Application.WorkbookDeactivate += Application_WorkbookDeactivate;
            }
            private void Application_WorkbookDeactivate(Excel.Workbook Wb)
            {
            }
            private void Application_WorkbookActivate(Excel.Workbook Wb)
            {
                Office.CommandBar ContextMenu=Application.CommandBars["Cell"];
                ContextMenu.Controls.Add(Office.MsoControlType.msoControlButton,3,1);
                Office.CommandBarControl MySubMenu;            
            }

    >>if i want use different xml for 2007 then i have use it in different Project or code base , Right?
    If you mean context menu, it is not supported in Ribbon UI at all. Different projects would not work. I think you could achieve your requirement with above steps in the link.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, August 26, 2016 2:07 AM

All replies

  • Actually, there might not be any compatibility issues if you've developed a VSTO Add-In by using Visual Studio 2010 Tools for Office Runtime and targeting the project to .NET Framework 4.5.2, for more information see Running Solutions in Different Versions of Microsoft Office

    For the problem you facing with MS Office 2007, check the .NET version installed on the computer. And also check that on every Office host application your Add-In has been installed is not blocked or loading properly.


    Wednesday, August 24, 2016 6:07 AM
  • Hi daxesh,

    Could you share us your Ribbon XML? Which xmlns do you use for customUI? There are two xmlns,” http://schemas.microsoft.com/office/2009/07/customui” and http://schemas.microsoft.com/office/2006/01/customui. If you do not use new features like “Backstage View”, you could use “http://schemas.microsoft.com/office/2006/01/customui” which will work in Office 2007-2016.

    >> Do i have to implement ribbon button and context menu for Office 2007 differently than Ribbon xml approch ?

    If you used new function which is not supported in Office 2007, you will need to implement different Ribbon XML.

    >>Can Ribbon button and context menus for Office 2007 and Office applications 2010-2016 can co-exist?

    In VSTO project, you could not mix different customUIs in the same project.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Thursday, August 25, 2016 5:48 AM
  • Hi thank you so much Edward. 

    Here's is xml i am using

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">

    <ribbon>
    <tabs>
    <tab idMso="TabHome">
    <group id="grp"  label="laebl" >
    <button id="spltBtn_btn" label="label" onAction="onAction" size="large" getImage="getImage" />
    </group>
    </tab>
    </tabs>
    </ribbon>
    <contextMenus>
    <contextMenu idMso="idMso">
    <menu id="id" getLabel="getLabel" getImage="getImage">
    <button id="id" onAction="onAction"  getLabel="getLabel" getImage="getImage"/>
    </menu>
    </contextMenu>
    </contextMenus>
    </customUI>

    ------------------------------------------------------------------------------------------------------------------------

    If i used new function which is not supported in Office 2007, I need to implement different Ribbon XML ,As you mentioned , In VSTO project, you could not mix different customUIs in the same project.

    So from this i am concluding that if i want use different xml for 2007 then i have use it in different Project or code base , Right?

    Thanks

    Thursday, August 25, 2016 8:41 AM
  • Hi daxesh,

    In Excel 2007, you can add controls to almost every context menu with VBA code. However, it is not possible to change some context menus such as the Shapes and Picture context menu with VBA. In addition, it is not possible to change context menus with RibbonX. You could refer the link below for more information.

    #Customizing Context Menus in All Versions of Microsoft Excel
    https://msdn.microsoft.com/en-us/library/office/gg469862(v=office.14).aspx

    In VSTO project, you could try above way, a simple code like below:

           private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                this.Application.WorkbookActivate += Application_WorkbookActivate;
                this.Application.WorkbookDeactivate += Application_WorkbookDeactivate;
            }
            private void Application_WorkbookDeactivate(Excel.Workbook Wb)
            {
            }
            private void Application_WorkbookActivate(Excel.Workbook Wb)
            {
                Office.CommandBar ContextMenu=Application.CommandBars["Cell"];
                ContextMenu.Controls.Add(Office.MsoControlType.msoControlButton,3,1);
                Office.CommandBarControl MySubMenu;            
            }

    >>if i want use different xml for 2007 then i have use it in different Project or code base , Right?
    If you mean context menu, it is not supported in Ribbon UI at all. Different projects would not work. I think you could achieve your requirement with above steps in the link.

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Friday, August 26, 2016 2:07 AM