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)
前次修改時間: 2015年4月24日
適用於: Excel 2010 | Office 2007 | Office 2010 | Open XML | PowerPoint 2010 | SharePoint Server 2010 | VBA | Word 2010
本文內容
Feature Overview
Setting Tab Activation
Auto-Scaling of Custom Controls
Conclusion
Additional Resources
Applies to: Microsoft Office 2010
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)
注意
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.
注意
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
Figure 2. Controls shown slightly more compressed
Figure 3. Controls shown more compressed
Figure 4. Group shown as a single button
注意
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.