Visual Studio Developer Center > Visual Studio Forums > Visual Studio Tools for Office > Is there a way to activate a certain Tab on the Ribbon?
Ask a questionAsk a question
 

AnswerIs there a way to activate a certain Tab on the Ribbon?

  • Thursday, December 28, 2006 7:44 PMkewpcg Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have a Word 2007 application level add-in that creates a custom tab on the ribbon ("MyTab").

    I would like to write code in the DocumentOpen to force "MyTab" to be the current active tab when certain documents are in use. 

    Is there a callback that will allow me to force a particular ribbon tab to be selected?

Answers

  • Friday, March 16, 2007 1:17 AMAndrew Whitechapel - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Unfortunately, the new ribbon model does not support the ability to programmatically set any control (control, group or tab) to be the active control. This is part of the design of the ribbon.

    The main idea behind this aspect of the design is that the user should never be "surprised" by changes in the UI. They should always be in control of the ribbon, as far as possible, with the exception of certain built-in behaviors of the app itself. Add-ins are not allowed to take part in this behavior. In this way, the user always has a consistent experience when working with the ribbon UI.

     

All Replies

  • Friday, January 05, 2007 8:47 AMMikkel Skovby Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    I would like to know this aswell. Got a button in my ribbon to open a template, and when the template opens, Word changes to the "home" tab. Would like to change back to my custom tab, but can't figure out how.
  • Friday, January 12, 2007 10:04 AMBernyInFrance Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Same question for me. I have a program in VBA that manage some particular documents, and my special Tab offerts some functions designed for this kind of documents. Therfore, my special Tab should be activated each time a new document of this kind is opened for consultation. So, why Microsoft Team did it so difficult to activate tabs ?

    For the moment, I use the vba function "SendKeys", but it is not very clean, et it does not always work :
    assuming that the keytip for my special tab is "JB", then I created this code in my vba program :

    Sub ActivateMyTab()
        ' Activate Word application to be sure keys will be send to the right application
        Application.Activate
        ' Be sure that the application is ready to receive my keys
        DoEvents
        ' Send 'Alt' key alone :
        SendKeys "%", True
        ' Then send the keytip  :
        SendKeys "JB{ENTER}", True
    End sub
  • Friday, March 16, 2007 1:17 AMAndrew Whitechapel - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Unfortunately, the new ribbon model does not support the ability to programmatically set any control (control, group or tab) to be the active control. This is part of the design of the ribbon.

    The main idea behind this aspect of the design is that the user should never be "surprised" by changes in the UI. They should always be in control of the ribbon, as far as possible, with the exception of certain built-in behaviors of the app itself. Add-ins are not allowed to take part in this behavior. In this way, the user always has a consistent experience when working with the ribbon UI.

     

  • Friday, August 01, 2008 6:19 PME. Alex Davis Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Please consider adding this ability in the next release. While I understand your reasoning perfectly, there is another perspective.

     

    If I create a document-level customization that includes a specialized Ribbon tab, the users of that customized document may expect the specialized tab to be active by default when the document first opens (unless there is a remembered, "sticky", tab from the last time it was opened).

     

    It is, IMHO, disconcerting to see Home when I really want "mytab" for a particular customization.

     

    I think that your guideline is a good one in any case. However, please give the VSTO community the option to choose otherwise.

     

    Thanks!

     

    E. Alex Davis

    Oracle

     

  • Friday, August 01, 2008 9:44 PMMike WalkerMVP, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I agree with Andrew's comments but the rules don't always get followed as if you are in word and create a new table the tab will automatically set the newly added tabs TABLE TOOLS DESIGN which sort of breaks the rule by forcing the user down a User Interface path, now that is what we want access to and am sure if you forward this comment to the Office team they should become a little more consistent in their approach to these types of rule and not "Surprising" or letting designers design applications with the correct level of refinement and quality that we are capable of doing if empowered Wink

     

    Regards