How do I connect to an office fluent ribbon at runtime and add/manipulate a ribbon tab in c#? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How to add a custom Ribbon tab using VBA?VBA control over the ribbon?programmatically control ribbon in office add-in at runtimeDeploying a VSTO 2010 Addin in Office 2007Fluent Ribbon Contextual Tab ErrorVisual Studio 2015 Excel Debugger not workingPowerPoint Web Add-In Ribbon Manipulation at RuntimeExcel Office Fluent Ribbon - Populate ComboBox OnLoadHow do I add tooltips to my Custom Excel Ribbon UI?

latest version of QGIS fails to edit attribute table of GeoJSON file

Random body shuffle every night—can we still function?

First paper to introduce the "principal-agent problem"

How much damage would a cupful of neutron star matter do to the Earth?

How to ask rejected full-time candidates to apply to teach individual courses?

Are there any irrational/transcendental numbers for which the distribution of decimal digits is not uniform?

Sally's older brother

How do I say "this must not happen"?

Why are current probes so expensive?

Short story about astronauts fertilizing soil with their own bodies

What did Turing mean when saying that "machines cannot give rise to surprises" is due to a fallacy?

An isoperimetric-type inequality inside a cube

How many time has Arya actually used Needle?

Should man-made satellites feature an intelligent inverted "cow catcher"?

Is the time—manner—place ordering of adverbials an oversimplification?

How to achieve cat-like agility?

2018 MacBook Pro won't let me install macOS High Sierra 10.13 from USB installer

Where and when has Thucydides been studied?

Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?

Marquee sign letters

How do you write "wild blueberries flavored"?

Does the universe have a fixed centre of mass?

Weaponising the Grasp-at-a-Distance spell

Pointing to problems without suggesting solutions



How do I connect to an office fluent ribbon at runtime and add/manipulate a ribbon tab in c#?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How to create Excel (.XLS and .XLSX) file in C# without installing Ms Office?How to add a custom Ribbon tab using VBA?VBA control over the ribbon?programmatically control ribbon in office add-in at runtimeDeploying a VSTO 2010 Addin in Office 2007Fluent Ribbon Contextual Tab ErrorVisual Studio 2015 Excel Debugger not workingPowerPoint Web Add-In Ribbon Manipulation at RuntimeExcel Office Fluent Ribbon - Populate ComboBox OnLoadHow do I add tooltips to my Custom Excel Ribbon UI?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I want to connect to a running excel, or launch excel, and at run time add a tab on the root / main ribbon /menubar. When I connect with interop to the excel application object I see a dynamic object menubar. It resolves at runtime to a .com object that I can't parse.



I can iterate into each menu and see menu.name, ID, and menu item. It looks like the ribbon items in my running excel, but i can't add or remove or influence items at run time. The menus, menu, menuitem are all Microsoft private. What am i missing to resolve and add/manipulate/remove my own runtime menu items? I don't want to write and compile static or runtime xml (yet). I see other vendors do this. What assembly or include am i missing? Here is what I have from pure hacking it out.



using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using Microsoft.Office.Core;
using System . Linq . Expressions;
using Microsoft . Office . Interop . Outlook;
using Microsoft . Office . Interop . Excel;
using System .Diagnostics;
using System . Runtime . InteropServices;
using System . Runtime . InteropServices . ComTypes;
using System . Diagnostics . Contracts;
using System . Windows . Controls . Ribbon;
using Microsoft . Office . Tools . Excel;
using Microsoft . Office . Tools . Ribbon;
using System . ComponentModel . Design;
using System . Reflection;
using Microsoft . Office . Interop . Access;

private static void ExcelChops ( )

Process [ ] Running = Process . GetProcessesByName ( "Excel" );
if ( Running . Count()==0 )

return;


Microsoft . Office . Interop . Excel . Application ExcelApplication = ( Microsoft . Office . Interop . Excel . Application ) Marshal . GetActiveObject ( "Excel.Application" );
if ( ExcelApplication == null )

return;


string ActiveExcelApplicationCaption = ExcelApplication . Caption;
Windows ExcelWindows = ExcelApplication . Windows;
int ExcelWindowCount = ExcelWindows . Count;
XlWindowState WindowState = ExcelApplication . WindowState;
Window ExcelWindow = ExcelApplication . Windows [ 1 ];
String ExcelWindoWindowCaption = ExcelWindow . Caption;

System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Application Caption 0 " , ActiveExcelApplicationCaption ) );
System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Window Caption 0 " , ExcelWindoWindowCaption ) );
System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window Count 0 " , ExcelWindowCount ) );
System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window State 0 " , WindowState ) );
//Microsoft.Office.Interop.Excel.Panes panes = ExcelWindow . Panes;
//IteratePanes ( panes );

Microsoft.Office.Interop.Excel.MenuBar aMB = ExcelApplication . ActiveMenuBar;
IterateMenus ( aMB , 0 );
System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , "Completed" , ( ( ( System . Environment . StackTrace ) . Split ( 'n' ) ) [ 2 ] . Trim ( ) ) ) );


private static void IterateMenus ( MenuBar aMB , int v )


string caption = aMB . Caption;
int ndx = aMB . Index;
dynamic parent = aMB . Parent;
Menus menus = aMB . Menus;
int menusCount = aMB . Menus . Count;

for ( int i = 1 ; i <= menusCount ; i++ )

Menu a = menus [ i ];
int b = a . Index;
string c = a . Caption;
System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , b , c ) );
IterateMenus ( a , v + 1 );




private static void IterateMenus ( Menu A , int v )

string caption = A . Caption;
int ndx = A . Index;
MenuItems items = A . MenuItems;
int itemsCount = items . Count;

for ( int i = 1 ; i <= itemsCount ; i++ )

dynamic a = items [ i ];
Type t = a.GetType ( );

object o = a as object;
Type to = o . GetType ( );
String oo = to . ToString ( );
var occ = to . Name;
var ooc = to . TypeHandle;

System . Diagnostics . Debug . WriteLine ( String . Format ( "menu item 0 of 1 2 3 " , i , itemsCount, occ, caption) );











share|improve this question






























    0















    I want to connect to a running excel, or launch excel, and at run time add a tab on the root / main ribbon /menubar. When I connect with interop to the excel application object I see a dynamic object menubar. It resolves at runtime to a .com object that I can't parse.



    I can iterate into each menu and see menu.name, ID, and menu item. It looks like the ribbon items in my running excel, but i can't add or remove or influence items at run time. The menus, menu, menuitem are all Microsoft private. What am i missing to resolve and add/manipulate/remove my own runtime menu items? I don't want to write and compile static or runtime xml (yet). I see other vendors do this. What assembly or include am i missing? Here is what I have from pure hacking it out.



    using System;
    using System . Collections . Generic;
    using System . Linq;
    using System . Text;
    using System . Threading . Tasks;
    using Microsoft.Office.Core;
    using System . Linq . Expressions;
    using Microsoft . Office . Interop . Outlook;
    using Microsoft . Office . Interop . Excel;
    using System .Diagnostics;
    using System . Runtime . InteropServices;
    using System . Runtime . InteropServices . ComTypes;
    using System . Diagnostics . Contracts;
    using System . Windows . Controls . Ribbon;
    using Microsoft . Office . Tools . Excel;
    using Microsoft . Office . Tools . Ribbon;
    using System . ComponentModel . Design;
    using System . Reflection;
    using Microsoft . Office . Interop . Access;

    private static void ExcelChops ( )

    Process [ ] Running = Process . GetProcessesByName ( "Excel" );
    if ( Running . Count()==0 )

    return;


    Microsoft . Office . Interop . Excel . Application ExcelApplication = ( Microsoft . Office . Interop . Excel . Application ) Marshal . GetActiveObject ( "Excel.Application" );
    if ( ExcelApplication == null )

    return;


    string ActiveExcelApplicationCaption = ExcelApplication . Caption;
    Windows ExcelWindows = ExcelApplication . Windows;
    int ExcelWindowCount = ExcelWindows . Count;
    XlWindowState WindowState = ExcelApplication . WindowState;
    Window ExcelWindow = ExcelApplication . Windows [ 1 ];
    String ExcelWindoWindowCaption = ExcelWindow . Caption;

    System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Application Caption 0 " , ActiveExcelApplicationCaption ) );
    System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Window Caption 0 " , ExcelWindoWindowCaption ) );
    System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window Count 0 " , ExcelWindowCount ) );
    System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window State 0 " , WindowState ) );
    //Microsoft.Office.Interop.Excel.Panes panes = ExcelWindow . Panes;
    //IteratePanes ( panes );

    Microsoft.Office.Interop.Excel.MenuBar aMB = ExcelApplication . ActiveMenuBar;
    IterateMenus ( aMB , 0 );
    System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , "Completed" , ( ( ( System . Environment . StackTrace ) . Split ( 'n' ) ) [ 2 ] . Trim ( ) ) ) );


    private static void IterateMenus ( MenuBar aMB , int v )


    string caption = aMB . Caption;
    int ndx = aMB . Index;
    dynamic parent = aMB . Parent;
    Menus menus = aMB . Menus;
    int menusCount = aMB . Menus . Count;

    for ( int i = 1 ; i <= menusCount ; i++ )

    Menu a = menus [ i ];
    int b = a . Index;
    string c = a . Caption;
    System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , b , c ) );
    IterateMenus ( a , v + 1 );




    private static void IterateMenus ( Menu A , int v )

    string caption = A . Caption;
    int ndx = A . Index;
    MenuItems items = A . MenuItems;
    int itemsCount = items . Count;

    for ( int i = 1 ; i <= itemsCount ; i++ )

    dynamic a = items [ i ];
    Type t = a.GetType ( );

    object o = a as object;
    Type to = o . GetType ( );
    String oo = to . ToString ( );
    var occ = to . Name;
    var ooc = to . TypeHandle;

    System . Diagnostics . Debug . WriteLine ( String . Format ( "menu item 0 of 1 2 3 " , i , itemsCount, occ, caption) );











    share|improve this question


























      0












      0








      0








      I want to connect to a running excel, or launch excel, and at run time add a tab on the root / main ribbon /menubar. When I connect with interop to the excel application object I see a dynamic object menubar. It resolves at runtime to a .com object that I can't parse.



      I can iterate into each menu and see menu.name, ID, and menu item. It looks like the ribbon items in my running excel, but i can't add or remove or influence items at run time. The menus, menu, menuitem are all Microsoft private. What am i missing to resolve and add/manipulate/remove my own runtime menu items? I don't want to write and compile static or runtime xml (yet). I see other vendors do this. What assembly or include am i missing? Here is what I have from pure hacking it out.



      using System;
      using System . Collections . Generic;
      using System . Linq;
      using System . Text;
      using System . Threading . Tasks;
      using Microsoft.Office.Core;
      using System . Linq . Expressions;
      using Microsoft . Office . Interop . Outlook;
      using Microsoft . Office . Interop . Excel;
      using System .Diagnostics;
      using System . Runtime . InteropServices;
      using System . Runtime . InteropServices . ComTypes;
      using System . Diagnostics . Contracts;
      using System . Windows . Controls . Ribbon;
      using Microsoft . Office . Tools . Excel;
      using Microsoft . Office . Tools . Ribbon;
      using System . ComponentModel . Design;
      using System . Reflection;
      using Microsoft . Office . Interop . Access;

      private static void ExcelChops ( )

      Process [ ] Running = Process . GetProcessesByName ( "Excel" );
      if ( Running . Count()==0 )

      return;


      Microsoft . Office . Interop . Excel . Application ExcelApplication = ( Microsoft . Office . Interop . Excel . Application ) Marshal . GetActiveObject ( "Excel.Application" );
      if ( ExcelApplication == null )

      return;


      string ActiveExcelApplicationCaption = ExcelApplication . Caption;
      Windows ExcelWindows = ExcelApplication . Windows;
      int ExcelWindowCount = ExcelWindows . Count;
      XlWindowState WindowState = ExcelApplication . WindowState;
      Window ExcelWindow = ExcelApplication . Windows [ 1 ];
      String ExcelWindoWindowCaption = ExcelWindow . Caption;

      System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Application Caption 0 " , ActiveExcelApplicationCaption ) );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Window Caption 0 " , ExcelWindoWindowCaption ) );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window Count 0 " , ExcelWindowCount ) );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window State 0 " , WindowState ) );
      //Microsoft.Office.Interop.Excel.Panes panes = ExcelWindow . Panes;
      //IteratePanes ( panes );

      Microsoft.Office.Interop.Excel.MenuBar aMB = ExcelApplication . ActiveMenuBar;
      IterateMenus ( aMB , 0 );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , "Completed" , ( ( ( System . Environment . StackTrace ) . Split ( 'n' ) ) [ 2 ] . Trim ( ) ) ) );


      private static void IterateMenus ( MenuBar aMB , int v )


      string caption = aMB . Caption;
      int ndx = aMB . Index;
      dynamic parent = aMB . Parent;
      Menus menus = aMB . Menus;
      int menusCount = aMB . Menus . Count;

      for ( int i = 1 ; i <= menusCount ; i++ )

      Menu a = menus [ i ];
      int b = a . Index;
      string c = a . Caption;
      System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , b , c ) );
      IterateMenus ( a , v + 1 );




      private static void IterateMenus ( Menu A , int v )

      string caption = A . Caption;
      int ndx = A . Index;
      MenuItems items = A . MenuItems;
      int itemsCount = items . Count;

      for ( int i = 1 ; i <= itemsCount ; i++ )

      dynamic a = items [ i ];
      Type t = a.GetType ( );

      object o = a as object;
      Type to = o . GetType ( );
      String oo = to . ToString ( );
      var occ = to . Name;
      var ooc = to . TypeHandle;

      System . Diagnostics . Debug . WriteLine ( String . Format ( "menu item 0 of 1 2 3 " , i , itemsCount, occ, caption) );











      share|improve this question
















      I want to connect to a running excel, or launch excel, and at run time add a tab on the root / main ribbon /menubar. When I connect with interop to the excel application object I see a dynamic object menubar. It resolves at runtime to a .com object that I can't parse.



      I can iterate into each menu and see menu.name, ID, and menu item. It looks like the ribbon items in my running excel, but i can't add or remove or influence items at run time. The menus, menu, menuitem are all Microsoft private. What am i missing to resolve and add/manipulate/remove my own runtime menu items? I don't want to write and compile static or runtime xml (yet). I see other vendors do this. What assembly or include am i missing? Here is what I have from pure hacking it out.



      using System;
      using System . Collections . Generic;
      using System . Linq;
      using System . Text;
      using System . Threading . Tasks;
      using Microsoft.Office.Core;
      using System . Linq . Expressions;
      using Microsoft . Office . Interop . Outlook;
      using Microsoft . Office . Interop . Excel;
      using System .Diagnostics;
      using System . Runtime . InteropServices;
      using System . Runtime . InteropServices . ComTypes;
      using System . Diagnostics . Contracts;
      using System . Windows . Controls . Ribbon;
      using Microsoft . Office . Tools . Excel;
      using Microsoft . Office . Tools . Ribbon;
      using System . ComponentModel . Design;
      using System . Reflection;
      using Microsoft . Office . Interop . Access;

      private static void ExcelChops ( )

      Process [ ] Running = Process . GetProcessesByName ( "Excel" );
      if ( Running . Count()==0 )

      return;


      Microsoft . Office . Interop . Excel . Application ExcelApplication = ( Microsoft . Office . Interop . Excel . Application ) Marshal . GetActiveObject ( "Excel.Application" );
      if ( ExcelApplication == null )

      return;


      string ActiveExcelApplicationCaption = ExcelApplication . Caption;
      Windows ExcelWindows = ExcelApplication . Windows;
      int ExcelWindowCount = ExcelWindows . Count;
      XlWindowState WindowState = ExcelApplication . WindowState;
      Window ExcelWindow = ExcelApplication . Windows [ 1 ];
      String ExcelWindoWindowCaption = ExcelWindow . Caption;

      System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Application Caption 0 " , ActiveExcelApplicationCaption ) );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "nExcel Window Caption 0 " , ExcelWindoWindowCaption ) );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window Count 0 " , ExcelWindowCount ) );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "Excel Window State 0 " , WindowState ) );
      //Microsoft.Office.Interop.Excel.Panes panes = ExcelWindow . Panes;
      //IteratePanes ( panes );

      Microsoft.Office.Interop.Excel.MenuBar aMB = ExcelApplication . ActiveMenuBar;
      IterateMenus ( aMB , 0 );
      System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , "Completed" , ( ( ( System . Environment . StackTrace ) . Split ( 'n' ) ) [ 2 ] . Trim ( ) ) ) );


      private static void IterateMenus ( MenuBar aMB , int v )


      string caption = aMB . Caption;
      int ndx = aMB . Index;
      dynamic parent = aMB . Parent;
      Menus menus = aMB . Menus;
      int menusCount = aMB . Menus . Count;

      for ( int i = 1 ; i <= menusCount ; i++ )

      Menu a = menus [ i ];
      int b = a . Index;
      string c = a . Caption;
      System . Diagnostics . Debug . WriteLine ( String . Format ( "0 1 " , b , c ) );
      IterateMenus ( a , v + 1 );




      private static void IterateMenus ( Menu A , int v )

      string caption = A . Caption;
      int ndx = A . Index;
      MenuItems items = A . MenuItems;
      int itemsCount = items . Count;

      for ( int i = 1 ; i <= itemsCount ; i++ )

      dynamic a = items [ i ];
      Type t = a.GetType ( );

      object o = a as object;
      Type to = o . GetType ( );
      String oo = to . ToString ( );
      var occ = to . Name;
      var ooc = to . TypeHandle;

      System . Diagnostics . Debug . WriteLine ( String . Format ( "menu item 0 of 1 2 3 " , i , itemsCount, occ, caption) );








      c# excel com ribbon dynamictype






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 9 at 12:23









      mgraham

      4,80711318




      4,80711318










      asked Mar 9 at 0:42









      dr d b karrondr d b karron

      87213




      87213






















          1 Answer
          1






          active

          oldest

          votes


















          0














          The ribbon cannot be programmatically controlled as simply as you would hope.



          Prior to the ribbon, Office applications had access to MenuBar (undocumented for Excel) and CommandBar objects. A MenuBar is the classic type of menu (File, Edit, View, Window, Help, etc). A CommandBar is the classic type of toolbar (rows of buttons below the menu). With these objects, you could directly manipulate these legacy UI features.



          The ribbon is entirely different. With the ribbon, you are not given the ability to arbitrarily manipulate it. This is intended to protect one add-in from another. In order to work with the ribbon, you must have an Add-In to provide XML describing the ribbon configuration you'd like to apply. There are a few ways to create an Excel add-in:



          • Use Visual Studio Tools for Office (VSTO)

          • Create a COM library (cannot find a good online resource for this right now)


          • Here's an option using Visual Studio Code that I have never tried (not sure if this will work for your use case)

          Beyond that, I suggest you google for "excel addin ribbon" for various documentation on how to work with the ribbon from within your addin.



          The MenuBar and CommandBar objects and properties are still around for legacy and non-ribbon purposes (e.g. displaying a right-click menu). If you create new Application-level CommandBars in versions of Excel that have a ribbon, the new CommandBars are unceremoniously dumped into a generic tab where all the add-ins' CommandBars end up. Tweaking the built-in CommandBars isn't going to affect the built-in ribbon.






          share|improve this answer























          • I believe this can be done because I see other vendors fitting their private tabs into the built-in tabs on the ribbon.

            – dr d b karron
            Mar 31 at 18:13











          • @drdbkarron Yes, it can be done, but not by using the APIs that you are asking about. You have to use Ribbon XML to work with the ribbon.

            – Michael Gunter
            Apr 1 at 18:47











          • I need a clue. How can I do what I want with XML at runtime?

            – dr d b karron
            Apr 2 at 2:02











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072869%2fhow-do-i-connect-to-an-office-fluent-ribbon-at-runtime-and-add-manipulate-a-ribb%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          The ribbon cannot be programmatically controlled as simply as you would hope.



          Prior to the ribbon, Office applications had access to MenuBar (undocumented for Excel) and CommandBar objects. A MenuBar is the classic type of menu (File, Edit, View, Window, Help, etc). A CommandBar is the classic type of toolbar (rows of buttons below the menu). With these objects, you could directly manipulate these legacy UI features.



          The ribbon is entirely different. With the ribbon, you are not given the ability to arbitrarily manipulate it. This is intended to protect one add-in from another. In order to work with the ribbon, you must have an Add-In to provide XML describing the ribbon configuration you'd like to apply. There are a few ways to create an Excel add-in:



          • Use Visual Studio Tools for Office (VSTO)

          • Create a COM library (cannot find a good online resource for this right now)


          • Here's an option using Visual Studio Code that I have never tried (not sure if this will work for your use case)

          Beyond that, I suggest you google for "excel addin ribbon" for various documentation on how to work with the ribbon from within your addin.



          The MenuBar and CommandBar objects and properties are still around for legacy and non-ribbon purposes (e.g. displaying a right-click menu). If you create new Application-level CommandBars in versions of Excel that have a ribbon, the new CommandBars are unceremoniously dumped into a generic tab where all the add-ins' CommandBars end up. Tweaking the built-in CommandBars isn't going to affect the built-in ribbon.






          share|improve this answer























          • I believe this can be done because I see other vendors fitting their private tabs into the built-in tabs on the ribbon.

            – dr d b karron
            Mar 31 at 18:13











          • @drdbkarron Yes, it can be done, but not by using the APIs that you are asking about. You have to use Ribbon XML to work with the ribbon.

            – Michael Gunter
            Apr 1 at 18:47











          • I need a clue. How can I do what I want with XML at runtime?

            – dr d b karron
            Apr 2 at 2:02















          0














          The ribbon cannot be programmatically controlled as simply as you would hope.



          Prior to the ribbon, Office applications had access to MenuBar (undocumented for Excel) and CommandBar objects. A MenuBar is the classic type of menu (File, Edit, View, Window, Help, etc). A CommandBar is the classic type of toolbar (rows of buttons below the menu). With these objects, you could directly manipulate these legacy UI features.



          The ribbon is entirely different. With the ribbon, you are not given the ability to arbitrarily manipulate it. This is intended to protect one add-in from another. In order to work with the ribbon, you must have an Add-In to provide XML describing the ribbon configuration you'd like to apply. There are a few ways to create an Excel add-in:



          • Use Visual Studio Tools for Office (VSTO)

          • Create a COM library (cannot find a good online resource for this right now)


          • Here's an option using Visual Studio Code that I have never tried (not sure if this will work for your use case)

          Beyond that, I suggest you google for "excel addin ribbon" for various documentation on how to work with the ribbon from within your addin.



          The MenuBar and CommandBar objects and properties are still around for legacy and non-ribbon purposes (e.g. displaying a right-click menu). If you create new Application-level CommandBars in versions of Excel that have a ribbon, the new CommandBars are unceremoniously dumped into a generic tab where all the add-ins' CommandBars end up. Tweaking the built-in CommandBars isn't going to affect the built-in ribbon.






          share|improve this answer























          • I believe this can be done because I see other vendors fitting their private tabs into the built-in tabs on the ribbon.

            – dr d b karron
            Mar 31 at 18:13











          • @drdbkarron Yes, it can be done, but not by using the APIs that you are asking about. You have to use Ribbon XML to work with the ribbon.

            – Michael Gunter
            Apr 1 at 18:47











          • I need a clue. How can I do what I want with XML at runtime?

            – dr d b karron
            Apr 2 at 2:02













          0












          0








          0







          The ribbon cannot be programmatically controlled as simply as you would hope.



          Prior to the ribbon, Office applications had access to MenuBar (undocumented for Excel) and CommandBar objects. A MenuBar is the classic type of menu (File, Edit, View, Window, Help, etc). A CommandBar is the classic type of toolbar (rows of buttons below the menu). With these objects, you could directly manipulate these legacy UI features.



          The ribbon is entirely different. With the ribbon, you are not given the ability to arbitrarily manipulate it. This is intended to protect one add-in from another. In order to work with the ribbon, you must have an Add-In to provide XML describing the ribbon configuration you'd like to apply. There are a few ways to create an Excel add-in:



          • Use Visual Studio Tools for Office (VSTO)

          • Create a COM library (cannot find a good online resource for this right now)


          • Here's an option using Visual Studio Code that I have never tried (not sure if this will work for your use case)

          Beyond that, I suggest you google for "excel addin ribbon" for various documentation on how to work with the ribbon from within your addin.



          The MenuBar and CommandBar objects and properties are still around for legacy and non-ribbon purposes (e.g. displaying a right-click menu). If you create new Application-level CommandBars in versions of Excel that have a ribbon, the new CommandBars are unceremoniously dumped into a generic tab where all the add-ins' CommandBars end up. Tweaking the built-in CommandBars isn't going to affect the built-in ribbon.






          share|improve this answer













          The ribbon cannot be programmatically controlled as simply as you would hope.



          Prior to the ribbon, Office applications had access to MenuBar (undocumented for Excel) and CommandBar objects. A MenuBar is the classic type of menu (File, Edit, View, Window, Help, etc). A CommandBar is the classic type of toolbar (rows of buttons below the menu). With these objects, you could directly manipulate these legacy UI features.



          The ribbon is entirely different. With the ribbon, you are not given the ability to arbitrarily manipulate it. This is intended to protect one add-in from another. In order to work with the ribbon, you must have an Add-In to provide XML describing the ribbon configuration you'd like to apply. There are a few ways to create an Excel add-in:



          • Use Visual Studio Tools for Office (VSTO)

          • Create a COM library (cannot find a good online resource for this right now)


          • Here's an option using Visual Studio Code that I have never tried (not sure if this will work for your use case)

          Beyond that, I suggest you google for "excel addin ribbon" for various documentation on how to work with the ribbon from within your addin.



          The MenuBar and CommandBar objects and properties are still around for legacy and non-ribbon purposes (e.g. displaying a right-click menu). If you create new Application-level CommandBars in versions of Excel that have a ribbon, the new CommandBars are unceremoniously dumped into a generic tab where all the add-ins' CommandBars end up. Tweaking the built-in CommandBars isn't going to affect the built-in ribbon.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 11 at 18:16









          Michael GunterMichael Gunter

          10.5k11444




          10.5k11444












          • I believe this can be done because I see other vendors fitting their private tabs into the built-in tabs on the ribbon.

            – dr d b karron
            Mar 31 at 18:13











          • @drdbkarron Yes, it can be done, but not by using the APIs that you are asking about. You have to use Ribbon XML to work with the ribbon.

            – Michael Gunter
            Apr 1 at 18:47











          • I need a clue. How can I do what I want with XML at runtime?

            – dr d b karron
            Apr 2 at 2:02

















          • I believe this can be done because I see other vendors fitting their private tabs into the built-in tabs on the ribbon.

            – dr d b karron
            Mar 31 at 18:13











          • @drdbkarron Yes, it can be done, but not by using the APIs that you are asking about. You have to use Ribbon XML to work with the ribbon.

            – Michael Gunter
            Apr 1 at 18:47











          • I need a clue. How can I do what I want with XML at runtime?

            – dr d b karron
            Apr 2 at 2:02
















          I believe this can be done because I see other vendors fitting their private tabs into the built-in tabs on the ribbon.

          – dr d b karron
          Mar 31 at 18:13





          I believe this can be done because I see other vendors fitting their private tabs into the built-in tabs on the ribbon.

          – dr d b karron
          Mar 31 at 18:13













          @drdbkarron Yes, it can be done, but not by using the APIs that you are asking about. You have to use Ribbon XML to work with the ribbon.

          – Michael Gunter
          Apr 1 at 18:47





          @drdbkarron Yes, it can be done, but not by using the APIs that you are asking about. You have to use Ribbon XML to work with the ribbon.

          – Michael Gunter
          Apr 1 at 18:47













          I need a clue. How can I do what I want with XML at runtime?

          – dr d b karron
          Apr 2 at 2:02





          I need a clue. How can I do what I want with XML at runtime?

          – dr d b karron
          Apr 2 at 2:02



















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55072869%2fhow-do-i-connect-to-an-office-fluent-ribbon-at-runtime-and-add-manipulate-a-ribb%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved