Share via


Use Host Controls to extend the Excel and Word object model

You can now take advantage of new controls, called host controls, which extend some of the built-in Word and Excel objects of Office. Host controls that are added to Office documents behave like the native Office objects such as ranges, but with additional functionality, including events and data-binding capabilities. Host controls available in Word projects are Bookmark, XMLNode, and XMLNodes. Host controls available in Excel projects are NamedRange, XMLMappedRange, ListObject, and Chart. You can add host controls to your document from within Visual Studio, or through the Office user interface. Managed control hosting within Word and Excel documents reduces the differences between Office solution development and Windows solution development. Elements such as cells, ranges, lists, and bookmarks become first-class controls that are easily accessible in code.

Each host control is uniquely identified, enables data binding, and provides a more complete event model.

You can add host controls to your Word documents or Excel worksheets in one of four ways:

  • Because host controls are extended Office objects, you can add them to your document at design-time, from within Visual Studio, in the same manner you would add the native object. For example, you can add a Word Bookmark control to a document by opening the Insert menu and selecting Bookmark.
  • You can drag host controls from the Toolbox onto your documents and worksheets. Visual Studio Tools 2005 for Office adds the most common host controls to the Visual Studio Toolbox, and Word host controls are available in the Word Controls tab in Word projects.
Excel host controls are available in the Excel Controls tab of your project