Word Document (VBVstoWordDocument)

Introduction

This Sample demonstrates how to manipulate Word 2008 Content Controls in a VSTO document-level project. 

The Microsoft.Office.Interop.Word.Document object is central to programming Word. When you open a document or create a new document, you create a new Microsoft.Office.Interop.Word.Document object, which is added to the Documents collection(http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.documents.aspx) in Word. The document that has the focus is called the active document(http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._application.activedocument.aspx) and is represented by the ActiveDocument property of the Application object.

Visual Studio Tools for Office extends the Microsoft.Office.Interop.Word.Document object by providing the Microsoft.Office.Tools.Word.Document (http://msdn.microsoft.com/en-us/library/microsoft.office.tools.word.document(v=vs.80).aspx) object, which gives you access to all members of the Documents collection, as well as data-binding capabilities and additional events. For more information, see Host Items and Host Controls Overview(http://msdn.microsoft.com/en-us/library/9z4e3456(v=vs.80).aspx). Since the majority of your code will be written in the ThisDocument class, you can access members of ThisDocument with the Me or this object reference.

Building the Sample

Before you build the sample, you must install Microsoft office2007 on your Operation System.

Running the Sample

Using the Code

1. Create a Word 2010 Document project.

2. Add a new user control in the project.

3. Drag three buttons in the user control.

4. Add code to insert all types of content controls at runtime.

More Information

MSDN: User Account Control

http://msdn.microsoft.com/en-us/library/aa511445.aspx

Using VSTO Document Features in Application-Level Add-Ins

http://blogs.msdn.com/b/eric_carter/archive/2008/07/24/using-vsto-document-features-in-application-level-add-ins.aspx

fice Development with Visual Studio

http://blogs.msdn.com/b/vsto/

Word Object Model Overview

http://msdn.microsoft.com/en-us/library/kw65a0we(v=vs.80).aspx