共用方式為


Ribbon Extensibility in Office 2010: Tab Activation and Auto-Scaling

Summary: Tab activation and auto-scaling are added to the extensibility model of the ribbon in the Microsoft Office 2010 Fluent user interface. Explore these features in more detail in this article. (2 printed pages)

Applies to: Excel 2010 | Office 2007 | Office 2010 | Open XML | PowerPoint 2010 | SharePoint Server 2010 | VBA | Word 2010

In this article
Feature Overview
Setting Tab Activation
Auto-Scaling of Custom Controls
Conclusion
Additional Resources

Published:   November 2009

Contents

  • Feature Overview

  • Setting Tab Activation

  • Auto-Scaling of Custom Controls

  • Conclusion

  • Additional Resources

Feature Overview

Two frequently requested features from developers who create solutions that use the ribbon in the Microsoft Office Fluent user interface (UI) are tab activation and group auto-scaling. Tab activation enables you to activate a tab (bring a tab to the foreground) on demand. Auto-scaling enables ribbon groups to adapt their layout to best match the horizontal window size.

Setting Tab Activation

In Microsoft Office 2010, you activate a custom tab by using the ActivateTab method of the IRibbonUI object as follows.

expression.ActivateTab(tabID As String)

To activate the custom tab, expression returns an IRibbonUI object and tabID is a String-type parameter that specifies the custom tab identifier to become active.

You use the ActivateTabMso method for built-in tabs and ActivateTabQ for tabs shared between multiple add-ins. ActivateTabQ also requires an additional String-type parameter that specifies the namespace of the add-in as follows.

expression.ActivateTabQ(tabID As String, namespace As String)

Note

Activation only applies to tabs that are visible.

The following is an example of activating the built-in Data tab in Microsoft Excel 2010.

Private myRibbon As IRibbonUI
Sub OnLoad(ribbon As IRibbonUI)
   Set myRibbon = ribbon
   myRibbon.ActivateTabMso("TabData ") 
End Sub

Auto-Scaling of Custom Controls

In Office 2010, you enable auto-scaling by setting the autoScale attribute of the <group> tag to True as follows.

Note

Auto-scaling is set on a per-group basis.

autoScale="true"

When you enable auto-scaling for a group, and the ribbon is resized horizontally (always from right-to-left), the controls in that group also resize automatically from the normal size (see Figure 1) to a medium size (see Figures 2 and 3) to a smaller size (see Figure4) successively.

Figure 1. Controls shown at normal sized

Normal sized controls

Figure 2. Controls shown slightly more compressed

Slightly compressed sized controls

Figure 3. Controls shown more compressed

More compressed sized controls

Figure 4. Group shown as a single button

Groups shown in columns

Note

You can specify the icon that appears when the group is compressed to a single button by assigning an image to the group itself.

Conclusion

Tab activation enables you to activate (bring to the foreground) a particular tab on demand. Auto-scaling enables ribbon groups to adapt their layout to best match the horizontal window size. By using these features, you can address scenarios that you could not previously, and improve access to the UI for your customers.

Additional Resources

Find more information about the subjects discussed in this article at the following locations.

Acknowledgment: Thanks to my editor, Linda Cannon, for her help in preparing this article for publication.