Condividi tramite


Automating Word by Using Extended Objects

When you develop Word solutions in Visual Studio, you can use host items and host controls in your solutions. These are objects that extend certain commonly used objects in the Word object model (that is, the object model that is exposed by the primary interop assembly for Word), such as the Document and ContentControl objects. The extended objects behave like the Word objects they are based on, but they add additional events and data binding capabilities to the objects.

Applies to: The information in this topic applies to document-level projects and application-level projects for Word 2013 and Word 2010. For more information, see Features Available by Office Application and Project Type.

Host items and host controls are available in both application-level add-ins and document-level customizations, although the context in which these can be used is different for each type of solution. For more information, see Host Items and Host Controls Overview.

Document Host Item

Word projects give you access to the Document host item. The Document host item acts as a container for other controls, including host controls and Windows Forms controls, and it maintains information about the controls on its surface. The Document host item also provides most of the same members as the Document class, which is the corresponding class in the object model of Word.

For more information, see Document Host Item.

Word Host Controls

There are several host controls for Word that help you create, organize, and automate documents. Most of their functionality involves importing, presenting, and protecting data. These host controls provide events and data-binding capabilities that their counterparts in the native Word object model do not have.

In document-level projects, you can add any host control to your document at design time, or you can add content controls and bookmark controls at run time. In application-level projects, you can add content controls and bookmark controls to any open document at run time.

For more information about the host controls you can use in Word projects, see the following topics:

See Also

Tasks

How to: Add Content Controls to Word Documents

How to: Add Bookmark Controls to Word Documents

How to: Add XMLNode Controls to Word Documents

How to: Add XMLNodes Controls to Word Documents

How to: Resize Bookmark Controls

Walkthrough: Creating a Template By Using Content Controls

Walkthrough: Binding Content Controls to Custom XML Parts

Walkthrough: Creating Shortcut Menus for Bookmarks

Concepts

Host Items and Host Controls Overview

Programmatic Limitations of Host Items and Host Controls

Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time

Other Resources

Word Solutions