Megosztás a következőn keresztül:


Office UI Customization

You can programmatically customize the user interface (UI) of Microsoft Office applications by using Visual Studio Tools for Office. The UI features that you can customize include the following:

  • Actions panes and custom task panes.

  • Controls on documents.

  • Custom Ribbon UI.

  • Outlook form regions.

  • Smart tags.

  • Menus and toolbars.

  • Shortcut menus.

Comparison of UI Features

The following table compares the main UI features that you can customize in Microsoft Office projects.

Feature

Supported project types

Supported Microsoft Office applications

Can the component contain controls?

Actions pane

Document-level customizations

Excel 2003

Excel 2007

Word 2003

Word 2007

Yes; Windows Forms controls

Custom task panes

Application-level add-ins

Excel 2007

InfoPath 2007

Outlook 2007

PowerPoint 2007

Word 2007

Yes; Windows Forms controls

Outlook form regions

Application-level add-ins

Outlook 2007

Yes; Windows Forms controls or dedicated Outlook controls

Custom Ribbon UI

Document-level customizations

Application-level add-ins

Excel 2007

Outlook 2007

PowerPoint 2007

Word 2007

Yes; dedicated Ribbon controls

Controls on documents

Document-level customizations

Application-level add-ins (starting in Visual Studio 2008 Service Pack 1)

Excel 2007

Word 2007

Yes; Windows Forms controls and host controls

Smart tags

Document-level customizations

Application-level add-ins (starting in Visual Studio 2008 SP1)

Excel 2003

Excel 2007

Word 2003

Word 2007

No

Menus and toolbars

Document-level customizations

Application-level add-ins

Excel 2003

Outlook 2003

PowerPoint 2003

Project 2003

Visio 2003

Word 2003

Menus cannot contain controls

Toolbars can contain buttons

Actions Panes and Custom Task Panes

Task panes are user interface panels that are typically docked to one side of a window in a Microsoft Office application. Almost all Microsoft Office applications include built-in task panes. An example of a task pane is the Help task pane in Word.

Visual Studio Tools for Office provides 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.

  • You can add a custom task pane to an application-level add-in for the 2007 Microsoft Office system. 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 toolbar, 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 Overview.

Smart Tags

Smart tags are strings of text that have type information attached to them; when a text string that matches the criteria appears in a document, it is recognized and the user is able to perform actions appropriate for that type of string. For example, you could create a smart tag that recognizes stock symbols. When the user types an uppercase string of four letters, a list of stock-related actions, such as looking up a stock price on the Internet, could appear.

You can use Visual Studio Tools for Office to add smart tags to Word documents and Excel workbooks in document-level customizations. Starting in SP1, you can add smart tags to any open document or workbook by using an application-level project. 

For more information, see Smart Tags Overview.

Outlook Form Regions

Use form regions to add custom functionality to standard Microsoft Office Outlook 2007 forms. You can create form regions that extend any existing form with additional fields or controls. If you create a new form region by using Visual Studio Tools for Office, you can use only Windows Forms controls on the form region. If you import a form region that was designed in Outlook, then you can use only native Outlook controls.

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.

For more information, see Creating Outlook Form Regions.

Controls on Documents

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.

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. Starting in SP1, when you develop application-level projects for Excel or Word, you can programmatically add controls to any open document or workbook at run time.

For more information, see Host Items and Host Controls Overview and Windows Forms Controls on Office Documents Overview.

Custom Ribbon UI

You can customize the Ribbon UI to expose functionality that you add to applications in the 2007 Microsoft Office system. 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. 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.

You can add a menu to the menu bar of a Visual Studio Tools for Office solution and create a customized caption for the menu. You can add menu commands to new or existing menus, and you can remove them. However, customization must be done programmatically. You cannot modify menus or the menu bar from within Visual Studio at design time. For more information, see How to: Create Office Menus Programmatically.

Toolbars

You can add a toolbar to your Visual Studio Tools for Office solution to provide the user with easy access to tools and other document or workbook features. You can customize the toolbar in the same manner that you would customize the built-in toolbars by adding or removing buttons. You can also customize the location and the docking properties of a toolbar through code. However, customization must be done programmatically. You cannot modify toolbars from within Visual Studio at design time. For more information, see How to: Create Office Toolbars Programmatically.

Shortcut Menus

A shortcut menu appears when you right-click in a document in Word or a worksheet in Excel. You can set a shortcut menu to appear after an event takes place in a document, such as when a user right-clicks a document, workbook, or host control. You can add a number of different menu commands just as you would for a menu on the main menu bar. You can change a shortcut menu's location and size through code. For more information, see Walkthrough: Creating Shortcut Menus for Bookmarks.

See Also

Tasks

How to: Show the Developer Tab on the Ribbon

How to: Show Add-in User Interface Errors

How to: Create Office Menus Programmatically

How to: Create Office Toolbars Programmatically

How to: Interact with Windows Forms

Walkthrough: Collecting Data Using a Windows Form

Concepts

Ribbon Overview

Actions Pane Overview

Smart Tags Overview

Creating Outlook Form Regions

Custom Task Panes Overview

Using WPF Controls in Office Solutions

Change History

Date

History

Reason

July 2008

Added information about adding managed controls and smart tags to documents by using application-level add-ins.

SP1 feature change.