Call Custom Backstage Tab From Ribbon Button RRS feed

  • Question

  • I have a custom backstage view tab called "BR Print" and a custom button in the Print Preview tab ribbon.

    I would like to be able to display the custom "BR Print" backstage view tab by clicking on my custom button. Does anyone have any idea how to do this?

    Any help would be much appreciated!


    Friday, April 27, 2012 3:33 PM


All replies

  • Hi Louis

    I believe the only simple way is to use SendKeys to mimic the user pressing Alt+F followed by the keyboard shortcut for your Ribbon tab.

    As always with SendKeys, it's not guaranteed to always work, or to always work the way you intend. For example, if your code is executing in a non-English interface a different letter than "F" may be assigned to the main backstage (File) menu. Or Word may change the key assignment you define for the button in your Ribbon XML because it conflicts with another key assignment.

    The less simple approach would be to use the Ribbon Accessibility APIs:

    Cindy Meister, VSTO/Word MVP

    • Proposed as answer by JosephFox Monday, April 30, 2012 12:01 PM
    • Marked as answer by LCJ187 Tuesday, May 8, 2012 4:05 PM
    Sunday, April 29, 2012 5:56 AM
  • I decided to use the SendKeys option but have not had much success in getting it to work. In my XML, I have assigned a keytip ("BR6") my custom backstage view tab "BRPrint" (please see part of my code below)

     <tab id="brPrint" label="BR Print" keytip="BP6" insertBeforeMso="TabPrint" columnWidthPercent="25" >

    I then added an onAction callback to the "returnToBRPrint" method (shown below) which I cannot get to work. I initially thought that it was not working because I did not specifically identify which application or window should be in focus so tried to use "AppActivate "Microsoft Word" " which did not work either. Im aware that the post above stated SendKeys was unreliable but am I missing something? Just to note that I'm using Windows 7 as im aware that there was a bug with SendKeys using Vista.

    Has anyone got an idea on how I can solve this problem?

    Any help would be appreciated.


    <!-- XML for custom button -->

    <button id="btnBRPrint" label="BR Print" size="large" imageMso="FilePrint" onAction="BRPrinting.returnToBRPrint" />


    Sub returnToBRPrint(control As IRibbonControl)

    'Returns to the BR Print tab
    SendKeys "%{F}"
    SendKeys "%{BP6}"   'This line errors - Invalid procedure call or argument (even with this line commented out, it still doesn't navigate to the File tab)

    End Sub

    Tuesday, May 1, 2012 11:37 AM