Automating Word Applications (How Do I in Visual Studio Tools for Office)
Note |
Applies to |
---|---|
The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office. For more information, see Features Available by Application and Project Type. |
Project type
Microsoft Office version
|
This page provides links to Help for commonly performed tasks that make use of the Microsoft Office Word object model in Visual Studio Tools for Office. To see other categories of key tasks covered by Visual Studio Tools for Office Help, see How Do I in Visual Studio Tools for Office.
Programming Word
Word Solutions
Provides links to information about creating Word solutions in Visual Studio Tools for Office.Getting Started Programming Document-Level Customizations for Word
Describes what you need to know to get started creating document-level customizations for Word.Getting Started Programming Application-Level Add-Ins
Describes what you need to know to get started creating application-level add-ins for Word.Programming Application-Level Add-Ins
Describes the main programming tasks for creating application-level add-ins for Word.Programming Document-Level Customizations
Describes the main programming tasks for creating document-level customizations for Word.How to: Create Event Handlers in Visual Studio Tools for Office
Describes various ways to create event handlers in Visual Basic and C#, whether you are in Design view or Code view.
Documents
How to: Reference Documents in the Documents Collection
Shows how to refer to a Document object by using the document's name or its index value in the collection.How to: Create New Documents
Shows how to use the Add method to create a new Word document based on Normal.dot or based on a custom template.How to: Open Existing Documents
Demonstrates how to use the Open method to open the existing Word document specified by a fully qualified path and file name.How to: Save Documents
Demonstrates several ways to save and close Word documents.How to: Close Documents
Provides examples of using the Close method to close an active document without saving changes, or saving changes without prompting the user.How to: Display Documents in Print Preview
Provides an example showing how you can display a document in Print Preview mode by setting the active document's PrintPreview property to True.How to: Print Documents
Shows how you can use the PrintOut method to send a Word document (or part of a document) to a printer.How to: Protect Documents and Parts of Documents
Describes how to protect data in an Office document from being revised, and how to unprotect certain parts of the document.How to: Hide Text in Documents
Shows how to set the font of a range of text so that the text is hidden.
Content Controls
How to: Add Content Controls to Word Documents
Describes several ways to add content controls.How to: Protect Parts of Documents by Using Content Controls
Describes how to use content controls to prevent users from editing or deleting parts of documents.
Ranges
How to: Define and Select Ranges in Documents
Demonstrates how to define a range in a Word document by using the Range method of a Document object.How to: Count Characters in Documents
Explains how to determine the number of characters in a document by using the Count property of the Characters collection.How to: Reset Ranges in Word Documents
Shows how to use SetRange to resize an existing range.How to: Extend Ranges in Documents
Provides an example that shows how to define a Range object and extend it by using its MoveStart and MoveEnd methods.How to: Collapse Ranges or Selections in Documents
Shows how to collapse a Range in a Word object and insert new text.
Bookmarks
How to: Update Bookmark Text
Explains how you can use the Range property of a Bookmark object to insert text into a bookmark or replace text in a bookmark that already contains text.How to: Add Bookmark Controls to Word Documents
Describes several ways to add Bookmark controls.How to: Resize Bookmark Controls
Demonstrates the various ways to resize bookmark controls, including adding text to the bookmark, recreating the bookmark, and setting the start and end properties in the Properties window.Walkthrough: Creating Shortcut Menus for Bookmarks
Demonstrates how to write code in the BeforeRightClick event handler of a Bookmark control to display a shortcut menu when the user right-clicks text in a bookmark.
Searching
How to: Search for Text in Documents
Shows how you can use either the Selection or the Range object to search for text in Word documents.How to: Set Search Options in Word
Describes the two ways to set search options for selections in Word documents.How to: Loop Through Found Items in Documents
Demonstrates how to use the Found property of the Find method, which returns true whenever a searched-for item is found.How to: Search for and Replace Text in Documents
Shows how to use the Find object to loop through a document searching for specific text, formatting, or style, and use the Find object's Replacement property to replace any of the items found.How to: Restore Selections After Searches
Shows how you can restore the user's original selection after a search is completed.
Smart Tags
How to: Enable Smart Tags in Word and Excel
Demonstrates how to make smart tags visible.How to: Add Smart Tags to Word Documents
Shows how to add a simple smart tag to a Word document-level customization.How to: Create Smart Tags With Custom Recognizers in Word
Shows how to create a smart tag with a regular expression.Walkthrough: Creating a Smart Tag by Using a Document-Level Customization
Shows how to change the smart tag UI before and after recognizing a smart tag in a document-level customization.Walkthrough: Creating a Smart Tag by Using an Application-Level Add-In
Shows how to change the smart tag UI before and after recognizing a smart tag in an application-level add-in.
Tables
How to: Create Word Tables
Demonstrates how to add a simple table to a document and provides other examples of how to work with the Table object in Word.How to: Add Text and Formatting to Cells in Word Tables
Provides an example that shows how you can work with the Cell object to add text and formatting to table cells.How to: Add Rows and Columns to Word Tables
Provides the code needed to add a row and a column to a table.
Walkthroughs
Walkthrough: Calling Code from VBA in a Visual Basic Project
Demonstrates how to call code in a customization assembly for a Word document from VBA code in the document.Walkthrough: Creating a Template By Using Content Controls
Demonstrates how to use content controls to create structured and reusable content in a Word 2007 template.Walkthrough: Binding Content Controls to Custom XML Parts
Demonstrates how to bind content controls in a Word document to XML data that is stored in a Word 2007 document.Walkthrough: Binding Content Controls to Custom XML Parts
Demonstrates how to bind content controls in a Word 2007 document to XML data that is stored in the document.Walkthrough: Displaying Text in a Text Box in a Document Using a Button
Demonstrates some basic principles of using buttons and text boxes on Word documents.Walkthrough: Changing Document Formatting Using CheckBox Controls
Demonstrates how to use check box controls on a Word document to change text formatting.Walkthrough: Updating a Chart in a Document Using Radio Buttons
Demonstrates the basics of changing chart styles using option buttons on a document.Walkthrough: Binding Data to Controls on a Word Actions Pane
Demonstrates binding data to controls on an actions pane in Word. The controls demonstrate a master/detail relation between tables in a SQL Server database.Walkthrough: Creating Shortcut Menus for Bookmarks
Demonstrates how to write code in the BeforeRightClick event handler of a Bookmark control to display a shortcut menu when the user right-clicks text in a bookmark.
Working with Text
How to: Insert Text into Word Documents
Describes the three primary ways to insert text into Word documents.How to: Retrieve Start and End Characters in Ranges
Shows how to retrieve the character positions of the start and end positions of a range by retrieving the Start and End properties of the Range object.How to: Format Text in Documents
Shows how to use the Range object in Word to format text.How to: Exclude Paragraph Marks When Creating Ranges
Provides an example that shows how to control paragraph structure when inserting text into Word documents.How to: Search for Text in Documents
Shows how you can use either the Selection or the Range object to search for text in Word documents.
XML and Schemas
How to: Add Custom XML Parts to Document-Level Customizations
Demonstrates how to add a custom XML part to a Word document that is part of a document-level customization.How to: Add Custom XML Parts to Documents by Using Application-Level Add-Ins
Demonstrates how to add a custom XML part to a Word document by using an application-level add-in.How to: Add Custom XML Parts to Documents Without Starting Microsoft Office
Demonstrates how to add a custom XML part to a Word document that is on a server that does not have Microsoft Office installed.How to: Map Schemas to Word Documents Inside Visual Studio
Demonstrates how to map an XML schema to a document while the document is open in a Visual Studio Tools for Office project, using the same Word tools that you use when the document is open outside of Visual Studio.