Excel VSTO // creating a Variable Ribbon Add-In RRS feed

  • Question

  • Hello,


    I developed a few year ago  a  VSTO  workbook that I use very often.
    I would like to partly re-use  its  Ribbon in a more general-purpose Add-In.

    When this vsto workbook opens, it reads the names of all the worksheets and groups them by chapters.
    Based on these chapters and sheet names, the workbook creates  a  ribbon tab with:

    - several groups for the chapters in the workbook and 
    - several buttons within each group for each worksheet in a chapter

    This is very convenient to browse a large workbook with typically 100 sheets. 
    Currently the VSTO workbook creates an XML ribbon returned by the GetCustomUI  method.
    This code is executed only once when the workbook opens.
    Therefore, when sheets are added, they can appear in the Ribon only when the workbook is re-opened.
    This is a minor problem for my current use.

    My Question

    I would like to have the same functionality available for any workbook that I open.
    Therefore, I would like to create an Add-In for this purpose.
    Therefore, the groups and the buttons need to be re-created any time a workbook is activated.
    I could not figure out how to do this.

    My question is:

    How can I  create/re-create  a Ribbon Tab when a Workbook is activated,
    instead of when the Add-In is loaded?
    Or, is there another way to get a similar result?

    I found two unsatisfying solutions:
    - create 8 hidden groups with 16 hidden buttons and make them visible when needed (not very nice)
    - create a vsto workbook for this precise purpose and only use this one (unfortunately, i have many VSTO workbook applications)

    Maybe there is a very simple solution?

    Thanks for your suggestions,


    • Edited by Lalbatros Monday, June 13, 2016 1:15 PM
    Monday, June 13, 2016 1:06 PM


All replies