none
Repurposed Ribbon Control Not Performing Default Action RRS feed

  • Question

  • Hi,

    This is happening for all the buttons that I have repurposed.  Just to demonstrate that I am following the correct procedure.

    In my Ribbon1.xml

      <commands>

        <command idMso="VisualBasic" onAction="VisualBasicOnAction" />

      </commands>

    In Ribbon1.cs

    public void VisualBasicOnAction(Office.IRibbonControl control, bool cancelDefault)
            {
                     
                cancelDefault = false;
                  
            }

    C# callback method being called back but Excel 2010 is not switching to the VB Editor.

    Running Microsoft Office Home And Student 2010.

    Version 14.0.6123.5001 ( 32-bit )

    Please advise

    Many thanks

    Tony Hallett

    Monday, October 1, 2012 9:01 PM

Answers

  • Hi Tony

    This is one of those little, nasty oversights that give us black-and-blue spots where we bang our heads on the desktop or monitor...

    You need to correct the method signatures. Compare the declaration of the third parameter with what you have:

    public void VisualBasicOnAction(Office.IRibbonControl control, ref bool cancelDefault)


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by T Hallett Tuesday, October 2, 2012 10:26 AM
    Tuesday, October 2, 2012 6:09 AM
    Moderator

All replies

  • Hi Tony

    This is one of those little, nasty oversights that give us black-and-blue spots where we bang our heads on the desktop or monitor...

    You need to correct the method signatures. Compare the declaration of the third parameter with what you have:

    public void VisualBasicOnAction(Office.IRibbonControl control, ref bool cancelDefault)


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by T Hallett Tuesday, October 2, 2012 10:26 AM
    Tuesday, October 2, 2012 6:09 AM
    Moderator
  • Thanks Cindy,

    Unfortunately I had visited

    http://msdn.microsoft.com/en-us/library/office/bb462633%28v=office.12%29.aspx#Y1541

    Appears that Frank Rice is prone to mistakes

    http://msdn.microsoft.com/en-us/library/officehttp://msdn.microsoft.com/en-us/library/office/ee691833.aspx

    Tony Hallett

    Tuesday, October 2, 2012 10:39 AM
  • Hi Tony

    No one is perfect :-)

    My source of information for this kind of thing is Part 3 of the "Customizing the Office (2007) Ribbon User Interface for Developers that can be found at
    http://msdn.microsoft.com/en-us/office/aa905530.aspx


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, October 2, 2012 5:41 PM
    Moderator
  • Hi Cindy,

    That resource and the third in the series tells us that getImageMso is a callback attribute !

    Worse still is the Introduction to the Office 2010 Backstage View for Developers which mentions controls that cannot be used in the Backstage View such as the Gallery for which the getItemHeight callback signature has been provided as :

    string GetItemHeight(IRibbonControl control, int itemIndex)

    when in fact it is

    int GetItemHeight(IRibbonControl control).

    At least the callback was provided correctly when discussing the Gallery in the Ribbon articles !

    ( This is not the only callback signature error on the page )

    These articles appear in the Microsoft Office Developer Network Technical Articles and as such they should be nothing less than correct on matters of fact.  These callback method signatures require extra attention to detail from the Author as a developer cannot just use intellisense or reflector to resolve the error.

    Again, thanks for your help.

    Is there any chance that the article can be corrected ?

    Tony Hallett 

     


    Tuesday, October 2, 2012 11:17 PM
  • Hi Tony

    I note that this article was written during the beta phase of Office 20007. A number of things in the Ribbon XML did change from the beta used for this article and the final release. No idea if the mistakes come (soley) from that or not...

    The only way I know to correct documentation on MSDN is to use the "Community links" at the bottom of the page. I suspect, however, that in the case of these 2007 articles such content may not be looked at.

    At this point, if you have the time, I recommend noting the mistakes you've noticed using that tool and clicking NO where it asks whether the article was helpful. That will let you send the information to a place where it should get read. And in that I'd also note that the information is relevant and useful for later versions of Office/Word and should be reviewed and kept up-to-date.


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, October 3, 2012 3:07 AM
    Moderator