none
How to Handle ribbon controls at runtime RRS feed

  • Question

  • I am working on the word Add-in in Visual Studio 2008 , and want to access the id of ribbon contol at runtime, how do I get them?

    because once they loaded from ribbon.xml there id can not be fetched at runtime.

     

     

    Thursday, June 16, 2011 9:08 AM

Answers

  • +1 on Rich's reply. His example references the OnAction method in specific. There are a myriad of callback methods available for the control. You just have to A) add the name of the method to the XML of your control and then B) add the callback method to your Ribbon code file.

    In any of the callback methods, you can get the Id of the control and then use that ID any way you want.  Here is an MSDN topic that lists all of the callbacks that you can use for controls and some examples of how to get the ID - http://msdn.microsoft.com/en-us/library/aa338199(office.12).aspx.


    Norm Estabrook
    Thursday, June 16, 2011 6:27 PM
    Answerer

All replies

  • You need a call back …

        Public Sub ClkItemIcon(ByVal control As Office.IRibbonControl)

                Select Case control.Id

                    Case Is = "ClkAbout"

    “ClkItemIcon” is from the onAction command in the xml and “ClkAbout” is the control Id of the ribbon button.


    Kind Regards, Rich ... http://greatcirclelearning.com
    Thursday, June 16, 2011 10:07 AM
  • +1 on Rich's reply. His example references the OnAction method in specific. There are a myriad of callback methods available for the control. You just have to A) add the name of the method to the XML of your control and then B) add the callback method to your Ribbon code file.

    In any of the callback methods, you can get the Id of the control and then use that ID any way you want.  Here is an MSDN topic that lists all of the callbacks that you can use for controls and some examples of how to get the ID - http://msdn.microsoft.com/en-us/library/aa338199(office.12).aspx.


    Norm Estabrook
    Thursday, June 16, 2011 6:27 PM
    Answerer