How to: Programmatically Reset Ranges in Word Documents

 

Use the M:Microsoft.Office.Interop.Word.Range.SetRange(System.Int32,System.Int32) 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

  1. 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.

    No code example is currently available or this language may not be supported.

    The following code example can be used in an VSTO Add-in. This code uses the active document.

    No code example is currently available or this language may not be supported.

  2. Use M:Microsoft.Office.Interop.Word.Range.SetRange(System.Int32,System.Int32) to start the range at the second sentence and end it at the end of the fifth sentence.

    No code example is currently available or this language may not be supported.

To reset an existing range in a document-level customization

  1. The following example shows the complete example for a document-level customization. To use this code, run it from the ThisDocument class in your project.

    No code example is currently available or this language may not be supported.

To reset an existing range in an VSTO Add-in

  1. The following example shows the complete example for an VSTO Add-in. To use this code, run it from the ThisAddIn class in your project.

    No code example is currently available or this language may not be supported.

How to: Programmatically Extend Ranges in Documents
How to: Programmatically Define and Select Ranges in Documents
How to: Programmatically Retrieve Start and End Characters in Ranges
How to: Programmatically Collapse Ranges or Selections in Documents

Show: