Programmatically reset ranges in Word documents
Use the SetRange method to resize an existing range in a Microsoft Office Word document.
Applies to: The information in this topic applies to document-level projects and VSTO Add-in projects for Word. For more information, see Features available by Office application and project type.
To reset an existing range
Set an initial range starting with the first seven characters in the document.
The following code example can be used in a document-level customization.
The following code example can be used in a VSTO Add-in. This code uses the active document.
Use SetRange to start the range at the second sentence and end it at the end of the fifth sentence.
Document-Level Customization Example
To reset an existing range in a document-level customization
The following example shows the complete example for a document-level customization. To use this code, run it from the
ThisDocumentclass in your project.
VSTO Add-in example
To reset an existing range in a VSTO Add-in
The following example shows the complete example for a VSTO Add-in. To use this code, run it from the
ThisAddInclass in your project.