none
How to add my event handler to Built-In Control RRS feed

  • Question

  • Ok, so I've searched all over and can't seem to find the lead I need to figure this out.

    I have created a custom Ribbon for my Word AddIn (2010 & 2007) and I have included the Built-In Controls of ReviewAcceptChangeMenu and ReviewRejectChangeMenu (I want to leverage the Track Changes features of Word).  However, I want to do a teeney weeney bit of logic when the user clicks these buttons. I thought the best way would be to add my event handler to the button Click stack to do my teeney weeney bit of code and let the Built-In Code event handler do all the rest. 

    So, can someone point me in the direction to find the event handler name to add my handler to to do this?  OR, am I headed in a wrong/bad direction with this??

    The only alternative that I've been able to come up with is to implement my own "Accept" & "Reject" controls, but that seems to be a real waste of time and redundancy. 

    As Always, I much appreciate your answers.

    Thanks, Billwa992

    Tuesday, May 10, 2011 10:01 PM

Answers

  • Hi Bill

    You can modify a built-in control's behavior by repurposing the control in your Ribbon XML. That means you have a <commands> section (precedes the <ribbon> section) with a <command> element for each command. You identify the built-in command by its idMso and re-purpose it through an onAction attribute + callback. You callback then does its thing and you set the Cancel parameter for the callback to "false" so that Word then does it's thing...


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Monday, May 16, 2011 7:53 AM
    Wednesday, May 11, 2011 1:06 PM
    Moderator
  • Hi Cindy,

    Finally got back to this.  Did as you said (after reading up on the "commands" section of XML).  but I can't seem to get the Built-In Control event handler to work when I insert my callback routine.  Below is what I've done.

    My XML statement is:
    <command idMSO="ReviewRejectChangeAndMoveToNext" onAction="OnBtnDo" />

    My C# call back routine is:

    public void OnBtnDo(Office.IRibbonControl control, out bool cancelDef)  //  needed to add the "out" to the cancel parameter
            {
                cancelDef = false;
            }

    With break points, I've verified that I'm getting to my event handler, but my "track Change revision" is not being rejected via the Built-In handler.  It appears to me that the event is not propogating to the regular Built-In handler for processing.

    Any insights would be appreciated.

    Bill

    P.S. all of my custom controls and such are working just fine.  So the XML "big picture" seems to be working, I just can't seem to insert my handler in the Built-In control and still have it do all of it's Built-In functionality.

     

     



    • Marked as answer by billwa992 Friday, May 20, 2011 10:23 PM
    • Edited by billwa992 Friday, May 20, 2011 10:24 PM
    Wednesday, May 18, 2011 2:15 AM

All replies

  • Hi Bill

    You can modify a built-in control's behavior by repurposing the control in your Ribbon XML. That means you have a <commands> section (precedes the <ribbon> section) with a <command> element for each command. You identify the built-in command by its idMso and re-purpose it through an onAction attribute + callback. You callback then does its thing and you set the Cancel parameter for the callback to "false" so that Word then does it's thing...


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Bruce Song Monday, May 16, 2011 7:53 AM
    Wednesday, May 11, 2011 1:06 PM
    Moderator
  • Cindy,

    Thank you very much.  This sounds exactly like what I needed to move forward.  Never found the <commands> section info in my own searching attempts.

    Billwa992

    • Marked as answer by billwa992 Wednesday, May 11, 2011 2:52 PM
    • Unmarked as answer by billwa992 Wednesday, May 18, 2011 2:05 AM
    Wednesday, May 11, 2011 2:52 PM
  • Hi Cindy,

    Finally got back to this.  Did as you said (after reading up on the "commands" section of XML).  but I can't seem to get the Built-In Control event handler to work when I insert my callback routine.  Below is what I've done.

    My XML statement is:
    <command idMSO="ReviewRejectChangeAndMoveToNext" onAction="OnBtnDo" />

    My C# call back routine is:

    public void OnBtnDo(Office.IRibbonControl control, out bool cancelDef)  //  needed to add the "out" to the cancel parameter
            {
                cancelDef = false;
            }

    With break points, I've verified that I'm getting to my event handler, but my "track Change revision" is not being rejected via the Built-In handler.  It appears to me that the event is not propogating to the regular Built-In handler for processing.

    Any insights would be appreciated.

    Bill

    P.S. all of my custom controls and such are working just fine.  So the XML "big picture" seems to be working, I just can't seem to insert my handler in the Built-In control and still have it do all of it's Built-In functionality.

     

     



    • Marked as answer by billwa992 Friday, May 20, 2011 10:23 PM
    • Edited by billwa992 Friday, May 20, 2011 10:24 PM
    Wednesday, May 18, 2011 2:15 AM
  • Cindy,

    Figured this out, I didn't have the "bool cancelDef" marked as "out" in my call back routine.

    adding that took care of the problem.

    Thanks, billwa992

    Friday, May 20, 2011 10:23 PM