没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Customizing the 2007 Office Fluent Ribbon for Developers (Part 1
of 3)
Summary: Learn how to customize the 2007 Office Fluent user interface. Also learn how new
features in Microsoft Visual Studio 2005 Tools for the 2007 Microsoft Office System support RAD
development of Ribbon customizations. (40 printed pages)
Frank Rice, Microsoft Corporation
Ken Getz, MCW Technologies, LLC
Published: May 2006
Updated: October 2006
Applies to: Microsoft Office Access 2007, Microsoft Office Excel 2007, Microsoft Office Outlook
2007, Microsoft Office PowerPoint 2007, Microsoft Office Word 2007, Microsoft Visual Studio 2005
Tools for the 2007 Microsoft Office System, Microsoft Visual Studio 2005
Contents
An Improved User Interface
New Ways to Enhance the User's Experience
What About Existing Solutions?
Customizing the Fluent UI for Most Office Applications
Using Callbacks
Two Ways to Customize the Fluent UI
Adding Document-Based Add-ins to the Fluent UI
UI Customization in Access 2007
Creating an Access Application-Level Custom Ribbon
Loading Customizations at Run Time
Ribbon Customization Scenarios for Other Applications
Using COM Add-ins to Modify the Fluent UI
Working with Existing Command-Bar Add-Ins
Dynamically Updating the Fluent UI
Loading Images
Conclusion
Additional Resources
An Improved User Interface
Many of the applications in the 2007 Microsoft Office system have a new look. The new Microsoft
Office Fluent user interface (UI) replaces the current system of layered menus, toolbars, and task
panes with a simpler system optimized for efficiency and discoverability. The new Fluent UI has
improved context menus, Enhanced ScreenTips, a Mini toolbar, and keyboard shortcuts that help to
improve user efficiency and productivity.
Note:
The Fluent UI is implemented in several applications in the
2007 Microsoft Office release, including Microsoft Office
Access 2007, Microsoft Office Excel 2007, Microsoft Office
PowerPoint 2007, and Microsoft Office Word 2007. The
Ribbon is also available in Microsoft Office Outlook 2007 while
you edit an Outlook item. You can customize the Fluent UI
through a combination of XML markup and any
Microsoft .NET Framework–based language that is supported
in Microsoft Visual Studio. You can also customize the Fluent
UI by using Microsoft Visual Basic for Applications (VBA),
Microsoft Visual C++, and Microsoft Visual Basic 6.0.
New Ways to Enhance the User's Experience
Developers have taken advantage of the tools and programming structures in earlier versions of
Office to extend the Fluent UI in creative ways. For example, the command bars object model
enabled developers to build rich solutions in their custom Office applications. Continuing in that
tradition, UI extensibility introduces an innovative model that you can use to enhance the user
experience. You use extensible markup language (XML) and one of several conventional
programming languages to manipulate the components that make up the Fluent UI. Because XML
is plain text, you can create customization files in any text editor, which simplifies work with the
Fluent UI. You can also reuse custom Fluent UI files with a minimum of adjustments because each
application uses the same programming model.
Figure 1. The Fluent UI in applications in the 2007 Office release
Using XML markup files to customize the Fluent UI greatly reduces the need for complex add-ins
based on the command bars object model. However, add-ins written for previous versions of Office
will continue to work in the Fluent UI with little or no modification.
What About Existing Solutions?
In previous versions of Office, developers used the command bars object model to build the Visual
Basic code that modified the Fluent UI. In the 2007 release of Office, this legacy code continues to
work in most cases without modification. However, changes made to toolbars in Microsoft Office
2003 now appear on an Add-Ins tab. The type of customization that appears depends on the
original design of the add-in. For example, Office creates a Menu Commands group that contains
items added to the previous menu structure (such as the File menu, the Insert menu, and the
Tools menu). Office also creates a Toolbar Commands group that contains items added to the
previous built-in toolbars (such as the Standard toolbar, the Formatting toolbar, and the Picture
toolbar). In addition, custom toolbars that are added by an add-in or document appear in the
Custom Toolbars group on the Add-Ins tab.
Customizing the Fluent UI for Most Office Applications
You can create a custom application-level Fluent UI in Word 2007, in Excel 2007, or in PowerPoint
2007 in the following ways:
By using COM add-ins in managed or unmanaged code
By using application-specific add-ins, such as .ppam and .xlam files
By using templates (.dotm files) in Word 2007
Note:
Access 2007 and Outlook 2007 implement Ribbon
customizations in slightly different ways than the other Office
applications do.
In a typical scenario, code in a COM add-in contains a procedure that returns XML markup from an
external customization file or from XML contained in the code itself. When the application starts,
the add-in loads and runs the code that returns the XML markup. The code validates the XML
markup against an XSD schema (though that is optional), and then loads the XML into memory and
applies it to the Fluent UI. The modified Fluent UI then appears. Fluent UI commands and controls
use callback procedures to run code in the add-in.
Document-level customizations use the same XML markup and an Office Open XML Formats file
with one of these extensions: .docx, .docm, .xlsx, .xlsm, .pptx, or .pptm. For these solutions, you
create a customization file that contains the XML markup and save it to a folder. You then modify
the parts in the Office Open XML Formats container to point to the customization file. When you
open the document in the Office application, the application loads the customization file into
memory and applies it to the Fluent UI. The commands and controls then call code contained in the
document to provide functionality.
Using Callbacks
You specify callbacks to update properties and perform actions from your Fluent UI at run time. For
example, to specify an action that occurs when the user clicks a button on the Ribbon, you must
supply the onAction callback function for the button. The RibbonX markup looks like this:
Xml
Copy Code
<button id="myButton" onAction="MyButtonOnAction"
/>
This markup tells Office to call the MyButtonOnAction method when the button is clicked. The
MyButtonOnAction method has a specific signature depending on your choice of languages; here
is an example:
C#
Copy Code
public void MyButtonOnAction (IRibbonControl
control)
{
if (control.Id == "myButton")
{
System.Windows.Forms.MessageBox.Show("Button
clicked!");
}
}
Note:
Depending on how you create your customization, you may
need to add a reference to the System.Windows.Forms
assembly to call the MessageBox.Show method.
The MyButtonOnAction procedure must be declared as public. The control parameter carries the
unique id and tag properties of the control, which enables you to use the same callback procedure
for multiple controls.
Note:
All attributes in the Ribbon XML customization markup use
the camel-casing convention, which capitalizes the first
character of each word except the first word—examples
include onAction and insertBeforeMso.
Two Ways to Customize the Fluent UI
Applications that support the Ribbon (except Access 2007, as described later in this article) provide
two ways to customize the Fluent UI by using XML markup: by using Office Open XML Formats files
that contain XML markup, or by using COM add-ins that contain XML markup. (In the case of
Outlook, only COM add-ins can customize the Fluent UI.) Any changes that you specify in this XML
markup add incrementally to the existing Fluent UI. For example, providing XML markup that
identifies a custom tab adds a single tab to the existing tabs in the host application.
All controls in RibbonX markup must include one of the following identifiers.
Table 1. One of these identifiers must be used with all controls
剩余141页未读,继续阅读
资源评论
holy_wind
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功