Search code examples
ms-officevstoribbon

Ribbon instances per Document


I am using VSTO 3.0 and the ribbon designer gives me a ribbon that is apparently shared across documents.

So if I have Document specific state( number of XML marked up tags say) that needs to show up in the ribbon( or a toggle button ) then all documents seem to share the ribbon instance

How can I fix this TIA


Solution

  • Hook into an appropriate event (such as when the active document is changed) within the document model, and in that event invalidate the appropriate ribbon button (you'll need the id of the element from the original Ribbon xml you load).

    Then, when the refresh state callback for that button occurs, you can update the caption/image/enabled as required.