locked
how to get a ribbon button from custom ribbon tab RRS feed

  • Question

  • This is shared addin for excel 2007 using ribbonX, VS 2008

    When selection in excel changes, some ribbon should be grayed out

    I did this way,

    onload of ribbon, I save a reference of IRibbonUI to _ribbonUI

    then in ApplicationSheetSelectionChange event handler,

    _ribbonUI.InvalidateControl(

    "RibbonButton1");

    set RibbonButton1.getEnabled to a callback where I decide the button should be enabled or disabled

     

    public bool IsEnabledCallBack(IRibbonControl control)

    This works fine b/c in the callback, based on control.Id I can know which ribbon button

    However, I want to know if there is way that I can directly get hold of RibbonButton1 from _ribbonUI (not callback of ribbon button),  e.g: in ApplicationSelectionChange handler, can I disable a ribbon button directly?

    thanks


    Kids are blessing
    Friday, October 1, 2010 8:59 PM

Answers

  • I would think not, since the ribbon does not have an object model that can be controlled from VBA
    Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk
    • Marked as answer by Bessie Zhao Friday, October 8, 2010 9:12 AM
    Friday, October 1, 2010 10:24 PM

All replies

  • I would think not, since the ribbon does not have an object model that can be controlled from VBA
    Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk
    • Marked as answer by Bessie Zhao Friday, October 8, 2010 9:12 AM
    Friday, October 1, 2010 10:24 PM
  • I am using C#, Shared Com Add-In for excel 2007, not VSTO

    not familar with VBA,  is it possible to do soin C#?

     

    thanks 


    Kids are blessing
    Saturday, October 2, 2010 5:54 AM
  • I am not familiar with C#, but I would think not, since the only way to customise the ribbon is through XML and the only way to interact with the ribbon controls is through callbacks
    Bill Manville. Excel MVP, Oxford, England. www.manville.org.uk
    Saturday, October 2, 2010 6:24 AM
  • Bill is right, it does not matter which programming language we use.


    Kind regards, Dennis (http://xldennis.wordpress.com/)
    Saturday, October 2, 2010 1:07 PM