none
How to turn visibility of a label or button on a custom Ribbon tab ON and OFF dynamically in Outlook 2010/2013 RRS feed

  • Question

  • I have an Outlook Add-in with a custom Ribbon Tab with a couple of groups of buttons.  I'm using the Ribbon XML technique for defining the ribbon customization, and it works great.

    I need to add a label or a button that appears in one of the groups ... but only if a specified condition is true (whilst a particular section of code is running).

    I can add the button.  I can set the value returned by the "<controlName>_GetVisible" event handler, but that only fires once.  I'm not seeing any way to access the Ribbon object or the individual control objects from within code.

    Can I call the "<controlName>_GetVisible" handler from code?  If so, what do I use for the "Office.IRibbonControl control" parameter required?

    Is there a better way to do this?



    mdpowers

    Monday, December 30, 2013 11:50 PM

Answers

  • Call IRibbonUI.Invalidate().

    IRibbonUI can be cached when your implementation of OnLoad() callback is executed.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by mdpowers-slo Tuesday, December 31, 2013 3:14 AM
    Tuesday, December 31, 2013 1:21 AM

All replies

  • Call IRibbonUI.Invalidate().

    IRibbonUI can be cached when your implementation of OnLoad() callback is executed.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by mdpowers-slo Tuesday, December 31, 2013 3:14 AM
    Tuesday, December 31, 2013 1:21 AM
  • Wouldn't the IRibbonUI.Invalidate() turn off all of my customization?  And how would I cache the IRibbonUI?  I can't even find the objects; the customization is implemented via Ribbon XML, and everything that holds the objects appears to be completely hidden.  Unless you know where it's buried ... ;-)


    mdpowers

    Tuesday, December 31, 2013 2:17 AM
  • Nothing will be turned off - Outlook will invoke enabled/visible/image/text etc. callbacks specified in your ribbon XML.

    You are already processing GetVisible callback. OnLoad callback is specified on the ribbon level.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, December 31, 2013 2:35 AM
  • So the IRibbonUI.Invalidate() will just tell all the elements on the ribbon to invoke their individual visible callbacks?  It's that simple?

    Dmittry, you should write a book!  Finding the documentation on this stuff is rough!


    mdpowers

    Tuesday, December 31, 2013 2:43 AM
  • Got it to invoke the visible callback ... but for some reason the value that it was to return was 'stale', even though it had just been updated.  Oh, well, that can be tackled in morning.

    Thanks for your help, Dmitry!


    mdpowers

    Tuesday, December 31, 2013 3:17 AM
  • yep, it just tells Outlook that everything about the ribbon is invalid and must be updated.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Tuesday, December 31, 2013 3:56 AM