Jaa


Work with text in documents

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The topics in this section provide step-by-step procedures and code examples for using the object model of Microsoft Office Word to work with text in Office projects.

In some cases, the ways that you perform these tasks in VSTO Add-ins is different from the ways that you perform them in document-level customizations.

Task Procedure
Define ranges based on various criteria and select them. How to: Programmatically define and select ranges in documents
Get the characters that begin and end a range. How to: Programmatically retrieve start and end characters in ranges
Select a paragraph without including the paragraph mark, and move the text. How to: Programmatically exclude paragraph marks when creating ranges
Make a range larger or smaller. How to: Programmatically extend ranges in documents
Move a range to a different location and size. How to: Programmatically reset ranges in Word documents
Reduce a range or section to consist of only the insertion point. How to: Programmatically collapse ranges or selections in documents
Insert text into a document. How to: Programmatically insert text into Word documents
Format the text in a range. How to: Programmatically format text in documents
Add or replace text in a bookmark. How to: Programmatically update bookmark text
Find specific text by using a selection or a range and replace it. How to: Programmatically search for and replace text in documents
Specify how Word searches for text. How to: Programmatically set search options in Word
Iterate through search results. How to: Programmatically loop through found items in documents
Save the current selection and restore it after a search. How to: Programmatically restore selections after searches
Get the number of characters in a document, including hidden characters. How to: Programmatically count characters in documents
Hide the text in a bookmark before printing a document. How to: Programmatically hide text in documents
Add a comment to text. How to: Programmatically add comments to text in documents

See also