Getting Started Programming Document-Level Customizations for Word
If you are just getting started creating document-level customizations for Microsoft Office Word by using Visual Studio, here is what you need to know.
Applies to: The information in this topic applies to document-level projects for Word 2013 and Word 2010. For more information, see Features Available by Office Application and Project Type.
Understanding How Document-Level Customizations for Word Work
Each Word customization you create is based around a single document. To start using the customization, the end user opens the document or creates the document from a Word template. Events in the document, for example moving the cursor into specific areas or clicking buttons and menu items, can call event-handling methods in the assembly. When the document is closed, the features provided by the customization are no longer available in Word.
For more information, see Architecture of Document-Level Customizations.
Creating Document-Level Projects for Word
To create a document-level customization for Word, use the Word Document or Word Template project template in the New Project dialog box. These templates include required assembly references and project files.
For more information about how to create a document-level project for Word, see How to: Create Office Projects in Visual Studio. For more information about the project templates, see Office Project Templates Overview.
Programming Word Documents by Using Host Items Host Controls
Host items and host controls are classes that provide the programming model for document-level customizations.
Host items provide an entry point for your code, and they can also act as containers for host controls and Windows Forms controls. In document-level projects for Word, the host item is represented by the ThisDocument class.
Host controls are based on native Word objects, such as content controls, bookmarks, and XML nodes. Host controls provide similar functionality to the native Word objects, but they also have new events, designer support, and data-binding capability. They appear as first-class objects in your project code and in IntelliSense, which makes it easier to refer to specific objects directly in your code without having to navigate the Word object model.
For more information, see the following topics:
Customizing the User Interface of Word
Most Microsoft Office solutions modify the user interface (UI) of the Office application to provide some way for users to interact with the solution. There are many ways in which you can modify the UI of Word by using a document-level customization. For example, you can add controls to the ribbon, and you can display an actions pane. For more information, see Office UI Customization.
You can also open the document that is associated with your project directly in Visual Studio. When the document is open in Visual Studio, you can modify the document by using the Word user interface. You can also use the document as a design surface, which enables you to drag controls onto it. For more information, see Office Projects in the Visual Studio Environment.
Binding Controls to Data
The content controls and the Bookmark control are in the list of controls that you can drag from the Data Sources window. Adding content controls and bookmarks in this way automatically binds them to the data source that you set up by using the window. Without writing any code, you can display data from databases, services, and business objects. For more information, see Binding Data to Controls in Office Solutions.
Next Steps
To learn how to create a document-level customization for Word, see Walkthrough: Creating Your First Document-Level Customization For Word. This walkthrough introduces you to the Office development tools in Visual Studio and the programming model for Word document-level customizations.
For a list of topics that walk you through some of the common tasks in Word projects, see Common Tasks in Office Programming.
See Also
Tasks
How to: Create Office Projects in Visual Studio
Walkthrough: Creating Your First Document-Level Customization For Word
Concepts
Writing Code in Office Solutions