Export (0) Print
Expand All
Expand Minimize

How to: Reset Ranges in Word Documents

NoteNote

Some code examples in this topic use the this or Me keyword or the Globals class in a way that is specific to document-level customizations, or they rely on features of document-level customizations such as host controls. These examples can be compiled only if you have the required applications installed. For more information, see Features Available by Product Combination.

Use the SetRange method to resize an existing range in a Microsoft Office Word 2003 document.

To reset an existing range

  1. Set an initial range starting with the first seven characters in the document.

    object start = 0; 
    object end = 7; 
    Word.Range rng = this.Range(ref start,ref end); 
    
    
  2. Use SetRange to start the range at the second sentence and end it at the end of the fifth sentence.

    rng.SetRange(this.Sentences[2].Start, this.Sentences[5].End); 
    
    

The following example shows the entire procedure.

Example

object start = 0; 
object end = 7; 
Word.Range rng = this.Range(ref start,ref end); 

// Reset the existing Range. 
rng.SetRange(this.Sentences[2].Start, this.Sentences[5].End); 
rng.Select();

See Also

Community Additions

ADD
Show:
© 2014 Microsoft