Office UI 自定义Office UI customization

可以使用 Visual Studio 中的 Office 开发人员工具自定义 Microsoft Office 应用程序的用户界面 (UI)。You can customize the user interface (UI) of Microsoft Office applications by using the Office developer tools in Visual Studio. 本主题介绍自定义的 UI 功能,分为以下几个部分:This topic describes the UI features that you can customize in the following sections:

UI 功能的比较Comparison of UI Features

下表比较了 Microsoft Office 项目中可自定义的主要 UI 功能。The following table compares the main UI features that you can customize in Microsoft Office projects.

功能Feature 支持的项目类型Supported project types 支持的 Microsoft Office 应用程序Supported Microsoft Office applications
操作窗格Actions pane 文档级自定义项Document-level customizations ExcelExcel

Word
自定义任务窗格Custom task panes VSTO 外接程序VSTO Add-ins ExcelExcel

InfoPath 2013InfoPath 2013

InfoPath 2010InfoPath 2010

OutlookOutlook

PowerPointPowerPoint

Word

ExcelExcel
自定义功能区 UICustom Ribbon UI 文档级自定义项Document-level customizations

VSTO 外接程序VSTO Add-ins
ExcelExcel

InfoPath 2013InfoPath 2013

InfoPath 2010InfoPath 2010

OutlookOutlook

PowerPointPowerPoint

项目Project

Word

VisioVisio
Backstage 视图Backstage view 文档级自定义项Document-level customizations

VSTO 外接程序VSTO Add-ins
ExcelExcel

InfoPath 2013InfoPath 2013

InfoPath 2010InfoPath 2010

OutlookOutlook

PowerPointPowerPoint

项目Project

Word

VisioVisio
Outlook 窗体区域Outlook form regions VSTO 外接程序VSTO Add-ins OutlookOutlook
文档中的控件Controls on documents 文档级自定义项Document-level customizations

VSTO 外接程序VSTO Add-ins
ExcelExcel

Word
快捷菜单Shortcut menus 文档级自定义项Document-level customizations

VSTO 外接程序VSTO Add-ins
ExcelExcel

InfoPath 2013InfoPath 2013

InfoPath 2010InfoPath 2010

OutlookOutlook

PowerPointPowerPoint

项目Project

Word

VisioVisio

ExcelExcel

操作窗格和自定义任务窗格Actions panes and custom task panes

任务窗格是一个用户界面面板,通常停靠在 Microsoft Office 应用程序中某一窗口的一侧。Task panes are user interface panels that are typically docked to one side of a window in a Microsoft Office application. 几乎所有 Microsoft Office 应用程序都包括内置任务窗格。Almost all Microsoft Office applications include built-in task panes. Word 中的“帮助”任务窗格就是任务窗格的一个示例。An example of a task pane is the Help task pane in Word.

Visual Studio 中的 Office 开发工具提供了两种不同的自定义任务窗格方法:The Office development tools in Visual Studio provide two different ways to customize task panes:

  • 可以向文档级自定义项添加操作窗格。You can add an actions pane to a document-level customization. 默认情况下,操作窗格显示在应用程序的右边,在文档的右侧。By default, the actions pane is displayed on the right side of the application, to the right of the document. 但是,也可以在文档的左侧、顶部或底部显示操作窗格。However, the actions pane can also be displayed to the left, top, or bottom of the document.

  • 可以向 VSTO 外接程序添加自定义任务窗格。You can add a custom task pane to a VSTO Add-in. 用户可以将自定义任务窗格停靠到应用程序窗口中的各侧,也可将自定义任务窗格拖动到窗口中的任意位置。Users can dock custom task panes to different sides of the application window, or they can drag custom task panes to any location in the window.

    操作窗格和自定义任务窗格通过承载各种控件来提供功能,以协助用户进行数据输入等任务。Actions panes and custom task panes provide functionality by hosting a variety of controls to help users with tasks such as data entry. 与功能区组相比,操作窗格和自定义任务窗格提供更大的区域来包括文本和控件。Compared to a Ribbon group, actions panes and custom task panes provide a much larger area to include text and controls.

    有关操作窗格的详细信息,请参阅操作窗格概述For more information about actions panes, see Actions pane overview. 有关自定义任务窗格的详细信息,请参阅自定义任务窗格For more information about custom task panes, see Custom task panes.

自定义功能区 UICustom Ribbon UI

可以自定义功能区 UI,以显示在 Office 中添加到应用程序的功能。You can customize the Ribbon UI to expose functionality that you add to applications in Office. 功能区是一种以控件形式整理相关命令(便于查找)的方法。The Ribbon is a way to organize related commands (in the form of controls) so that they are easier to find. 可以创建你自己的功能区选项卡和组,以便用户能够访问解决方案中提供的功能。You can create your own Ribbon tabs and groups to give users access to functionality that you provide in your solution. 之前通过使用 Microsoft Office System 早期版本中的菜单和工具栏访问的大多数功能,现在都可以通过使用功能区进行访问。Most of the features that were accessed by using the menus and toolbars in earlier versions of the Microsoft Office system can now be accessed by using the Ribbon.

有关详细信息,请参阅功能区概述For more information, see Ribbon overview.

Backstage 视图Backstage view

在 Office 应用程序中,单击 "文件" 选项卡将打开 Backstage 视图。In Office applications, clicking the File tab opens the Backstage view. Backstage 视图提供的用户界面可将文件级别任务和操作组合到一起,从而代替可通过 2007 Microsoft Office system 中 Microsoft Office 按钮使用的类似功能。The Backstage view provides a UI that combines file-level tasks and actions, and replaces similar functionality available from the Microsoft Office button in the 2007 Microsoft Office system. Backstage 视图可通过使用 XML 完全扩展。The Backstage view is fully extensible by using XML.

Visual Studio 不提供用于自定义 Backstage 视图的设计器或 API。Visual Studio does not provide a designer or APIs for customizing the Backstage view. 但是,如果向 Office 项目添加 "功能区(XML) " 项,则可以向功能区 xml 文件添加 XML 以自定义 Backstage 视图。However, if you add a Ribbon (XML) item to your Office project, you can add XML to the Ribbon XML file to customize the Backstage view. 有关功能区(XML) 项的详细信息,请参阅功能区 XMLFor more information about Ribbon (XML) items, see Ribbon XML.

有关自定义 Backstage 视图的详细信息,请参阅面向开发人员的 office 2010 backstage 视图的简介为开发人员自定义 office 2010 backstage 视图For more information about customizing the Backstage view, see Introduction to the Office 2010 Backstage view for developers and Customize the Office 2010 Backstage view for developers.

Outlook 窗体区域Outlook form regions

使用窗体区域可向标准 Microsoft Office Outlook 窗体添加自定义功能。Use form regions to add custom functionality to standard Microsoft Office Outlook forms. 你可以使用额外字段或控件创建可扩展任何现有窗体的窗体区域。You can create form regions that extend any existing form with additional fields or controls. 如果使用 Visual Studio 中的 Office 开发工具创建新窗体区域,则在窗体区域上仅可使用 Windows 窗体控件。If you create a new form region by using the Office development tools in Visual Studio, you can use only Windows Forms controls on the form region. 如果导入在 Outlook 中设计的窗体区域,则仅可使用本机 Outlook 控件。If you import a form region that was designed in Outlook, then you can use only native Outlook controls.

你可以创建占用 Outlook UI 不同区域的窗体区域。You can create form regions that occupy different areas of the Outlook UI. 例如,窗体第一页的底部显示相邻窗体区域,每个相邻窗体区域都可折叠。For example, adjoining form regions are displayed at the bottom of the first page of a form, and each adjoining form region is collapsible. 还可以添加作为完整窗体页显示的单独窗体区域,并且该区域可以显示在任何现有标准窗体或自定义窗体上。You can also add a separate form region that is displayed as a full additional form page and that can appear on any existing standard form or custom form.

有关详细信息,请参阅创建 Outlook 窗体区域For more information, see Create Outlook form regions.

文档上的控件Controls on documents

可以向 Word 文档和 Excel 工作表添加各种控件。You can add a variety of controls to Word documents and Excel worksheets. 例如,你可能希望向文档添加日期选取器控件,以便用户可以标准格式输入日期,或者在工作表上设置一个按钮,用于将数据发送到数据库。For example, you might want to add a date picker control to a document so the user can enter dates in a standard format, or put a button on a worksheet to send data to a database.

开发 Excel 或 Word 文档级项目时,可以在设计时使用 Visual Studio 设计器向项目中的文档或工作簿添加控件,或在运行时以编程方式添加控件。When you develop document-level projects for Excel or Word, you can use the Visual Studio designer to add controls to the document or workbook in your project at design time, or you can programmatically add controls at run time. 开发 Excel 或 Word VSTO 外接程序项目时,可以在运行时以编程方式向任何打开的文档或工作簿添加控件。When you develop VSTO Add-in projects for Excel or Word, you can programmatically add controls to any open document or workbook at run time.

有关详细信息,请参阅主机项和主机控件概述Office 文档上的 Windows 窗体控件概述For more information, see Host items and host controls overview and Windows forms controls on Office documents overview.

快捷菜单Shortcut Menus

在文档或应用程序窗口中右键单击时,将出现一个快捷菜单。A shortcut menu appears when you right-click in a document or an application window. 可以设置在发生某事件后显示快捷菜单,例如,当用户右键单击文档、工作簿或主机控件时。You can set a shortcut menu to appear after an event takes place, such as when a user right-clicks a document, workbook, or host control. 可以向快捷菜单添加大量不同的菜单命令或控件。You can add a number of different menu commands or controls to a shortcut menu. 使用 XML 创建快捷菜单。Create shortcut menus by using XML. 如果向 Office 项目添加 "功能区(XML) " 项,则可以向功能区 xml 文件添加 xml 以创建快捷菜单。If you add a Ribbon (XML) item to your Office project, you can add XML to the Ribbon XML file to create shortcut menus. 有关使用 XML 创建快捷菜单的详细信息,请参阅如何:将命令添加到快捷菜单For more information about using XML to create shortcut menus, see How to: Add commands to shortcut menus.

请参阅See also