Document Class (2007 System)
Represents a document in Visual Studio Tools for Office projects for Microsoft Office Word.
Assembly: Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)
The class is the base class for document host items in Visual Studio Tools for Office projects. The class provides the same members as the Document class in the Word primary interop assembly, but it adds the following features:
Controls property. Use this property to add managed controls to a Word document, or remove controls, at run time.
VstoSmartTags property. Use this property to add smart tags to a document.
RemoveCustomization method. Use this method to remove the Visual Studio Tools for Office customization assembly from the document in a document-level customization.
CreateRibbonObjects method. Override this method if you added multiple custom Ribbons to your project by using the Ribbon (Visual Designer) item template, and you want to specify which Ribbons to display at run time.
GetAutomationObject method. Override this method to expose a class in your project to VBA code in the document.
Document-level events, such as BeforeClose and BeforeSave, that are provided only at the application level in the Word object model. That is, in the Word object model, these events are defined in the Application class rather than the Document class.
Creating Document Host Items
In application-level projects created by using Visual Studio 2008 Service Pack 1 (SP1), you can create objects programmatically by using the GetVstoObject method of any Document object. For more information, see Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time.
In document-level projects, you cannot create a object programmatically. Instead, use the ThisDocument class to programmatically access the document in your project. Visual Studio generates this class in your project at design time. The ThisDocument class derives from the class, and it is instantiated automatically by the Visual Studio Tools for Office runtime when the end user opens the document. For more information, see Programming Document-Level Customizations.