Document Host Item
The Document host item is a type that extends the Microsoft.Office.Interop.Word.Document type from the primary interop assembly for Word. The Document host item provides all of the same properties, methods, and events as a Microsoft.Office.Interop.Word.Document object, but it also exposes additional events and acts as a container for host controls and Windows Forms controls.
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.
To access the document in your project, use the ThisDocument class. When you create a document-level project, Visual Studio generates the ThisDocument class to serve as the communication link between Word and your customization code. The ThisDocument class gives you access to members of the Document host item to perform basic tasks in your customization, such as running code when the document is opened or closed. You can also use the class to add controls to the document. By combining different sets of controls and writing code, you can bind the controls to data, collect information from the user, and respond to user actions. For more information, see Programming Document-Level Customizations.
The ThisDocument class provides a location in which you can start writing code in your project. Because the class provides all of the same properties, methods, and events as the Microsoft.Office.Interop.Word.Document object in the primary interop assembly for Word, you can also use ThisDocument to access the object model of Word. For more information, see Word Object Model Overview.
A document-level project can contain only one Document host item (that is, the ThisDocument class). You cannot add new Document host items to your project at design time, and you cannot create new Document host items at run time from a document-level customization.
If you create a new Word document at run time, it will be of the type Microsoft.Office.Interop.Word.Document. Because it is not a host item, it cannot contain any host controls or Windows Forms controls. For more information about creating documents at run time, see How to: Programmatically Create New Documents.
In application-level projects, you can generate a Document host item at run time for any document that is open in Word. You can use the Document host item to add controls to the associated document, or to handle events that are not available on Microsoft.Office.Interop.Word.Document objects.
To generate a Document host item, use the GetVstoObject method. For more information, see Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time.