Range Interface

Definition

Represents a contiguous area in a document.

public interface class Range
[System.Runtime.InteropServices.Guid("0002095E-0000-0000-C000-000000000046")]
public interface Range
type Range = interface
Public Interface Range
Attributes

Remarks

Each Range object is defined by a starting and ending character position. Similar to the way bookmarks are used in a document, Range objects are used to identify specific portions of a document. However, unlike a bookmark, a Range object only exists while the programming code that defined it is running. Range objects are independent of the selection. That is, you can define and manipulate a range without changing the selection. You can also define multiple ranges in a document, while there can be only one selection per pane.

Use the Range(Object, Object) method to return a Range object defined by the given starting and ending character positions.

Use the Range property of an individual object to return a Range object defined by the beginning and end of the object. The Range property applies to many objects (for example, Paragraph, Bookmark, and Cell).

Properties

Application

Returns an Application object that represents the Microsoft Word application.

Bold

Determines if the font or range is formatted as bold.

BoldBi

Determines if the font or range is formatted as bold.

BookmarkID

Returns the number of the bookmark that encloses the beginning of the specified selection or range; returns 0 (zero) if there's no corresponding bookmark.

Bookmarks

Returns a Bookmarks collection that represents all the bookmarks in a range.

Borders

Returns a Borders collection that represents all the borders for the specified object.

CanEdit

Reserved for internal use.

CanPaste

Reserved for internal use.

Case

Returns or sets a WdCharacterCase constant that represents the case of the text in the specified range.

Cells

Returns a Cells collection that represents the table cells in a range.

Characters

Returns a Characters collection that represents the characters in a range.

CharacterStyle

Returns a Object that represents the style used to format one or more characters. Read-only.

CharacterWidth

Returns or sets the character width of the specified range.

Columns

Returns a Columns collection that represents all the table columns in the range.

CombineCharacters

Determines if the specified range contains combined characters.

Comments

Returns a Comments collection that represents all the comments in the specified range.

Conflicts

Gets a Conflicts collection object that contains all the conflict objects in the range.

ContentControls

Returns a ContentControls collection that represents the content controls contained within a range. Read-only.

Creator

Returns a 32-bit integer that indicates the application in which the specified object was created.

DisableCharacterSpaceGrid

Determines if Microsoft Word ignores the number of characters per line for the range.

Document

Returns a Document object associated with the specified range.

Duplicate

Returns a Range object that represents all the properties of the specified range.

Editors

Returns an Editors object that represents all the users authorized to modify a selection or range within a document.

EmphasisMark

Returns or sets the emphasis mark for a character or designated character string.

End

Returns or sets the ending character position of a range.

EndnoteOptions

Returns a EndnoteOptions object that represents the endnotes in a range or selection.

Endnotes

Returns a Endnotes collection that represents all the endnotes in a range.

EnhMetaFileBits

Returns a picture representation of how a selection or range of text appears.

Fields

Returns a read-only Fields collection that represents all the fields in the range.

Find

Returns a Find object that contains the criteria for a find operation.

FitTextWidth

Returns or sets the width (in the current measurement units) in which Microsoft Word fits the text in the current range.

Font

Returns or sets a Font object that represents the character formatting of the specified object.

FootnoteOptions

Returns a FootnoteOptions object that represents the footnote options in a range.

Footnotes

Returns a Footnotes collection that represents all the footnotes in a range.

FormattedText

Returns or sets a Range object that includes the formatted text in the specified range or selection.

FormFields

Returns a FormFields collection that represents all the form fields in the range.

Frames

Returns a Frames collection that represents all the frames in a range.

GrammarChecked

Determines if a grammar check has been run on the specified range.

GrammaticalErrors

Returns a ProofreadingErrors collection that represents the sentences that failed the grammar check on the specified range.

HighlightColorIndex

Returns or sets the highlight color for the specified range.

HorizontalInVertical

Returns or sets the formatting for horizontal text set within vertical text.

HTMLDivisions

Returns a HTMLDivisions object that represents an HTML division in a Web document.

Hyperlinks

Returns a Hyperlinks collection that represents all the hyperlinks in the specified range.

ID

Returns or sets the identifying label for the specified object when the current document is saved as a Web page.

Information[WdInformation]

Returns information about the specified selection or range.

InlineShapes

Returns a InlineShapes collection that represents all the InlineShape objects in a document, range, or selection.

IsEndOfRowMark

Determines if the specified range is collapsed and is located at the end-of-row mark in a table.

Italic

Determines if the range is formatted as italic.

ItalicBi

Determines if the range is formatted as italic.

Kana

Returns or sets whether the specified range of Japanese language text is hiragana or katakana.

LanguageDetected

Returns or sets a value that specifies whether Microsoft Word has detected the language of the specified text.

LanguageID

Returns or sets the language for the specified object.

LanguageIDFarEast

Returns or sets an East Asian language for the specified object.

LanguageIDOther

Returns or sets the language for the specified object.

ListFormat

Returns a ListFormat object that represents all the list formatting characteristics of a range.

ListParagraphs

Returns a ListParagraphs collection that represents all the numbered paragraphs in the range.

ListStyle

Returns an Object that represents the style used to format a bulleted list or numbered list. Read-only.

Locks

Gets a CoAuthLocks collection object that represents all the locks in the range.

NextStoryRange

Returns a Range object that refers to the next story as shown in the following table.

NoProofing

Determines if the spelling and grammar checker ignores the specified text.

OMaths

Returns an OMaths collection that represents the OMath objects within the specified range. Read-only.

Orientation

Returns or sets the orientation of text in a range when the Text Direction feature is enabled.

PageSetup

Returns a PageSetup object that's associated with the specified range.

ParagraphFormat

Returns or sets a ParagraphFormat object that represents the paragraph settings for the specified range.

Paragraphs

Returns a Paragraphs collection that represents all the paragraphs in the specified range.

ParagraphStyle

Returns an Object that represents the style used to format a paragraph. Read-only.

Parent

Returns an object that represents the parent object of the specified object.

ParentContentControl

Returns a ContentControl object that represents the parent content control for the specified range. Read-only.

PreviousBookmarkID

Returns the number of the last bookmark that starts before or at the same place as the specified range.

ReadabilityStatistics

Returns a ReadabilityStatistics collection that represents the readability statistics for the specified range.

Revisions

Returns a Revisions collection that represents the tracked changes in the range.

Rows

Returns a Rows collection that represents all the table rows in a range.

Scripts

Returns a Scripts collection that represents the collection of HTML scripts in the specified object.

Sections

Returns a Sections collection that represents the sections in the specified range.

Sentences

Returns a Sentences collection that represents all the sentences in the range.

Shading

Returns a Shading object that refers to the shading formatting for the specified object.

ShapeRange

Returns a ShapeRange collection that represents all the Shape objects in the specified range.

ShowAll

Determines if all nonprinting characters (such as hidden text, tab marks, space marks, and paragraph marks) are displayed.

SmartTags

Returns a SmartTags object that represents a smart tag in a range.

SpellingChecked

Determines if spelling has been checked throughout the specified range.

SpellingErrors

Returns a ProofreadingErrors collection that represents the words identified as spelling errors in the specified range.

Start

Returns or sets the starting character position of a range.

StoryLength

Returns the number of characters in the story that contains the specified range.

StoryType

Returns the story type for the specified range.

Style

Returns or sets the style for the specified object.

Subdocuments

Returns a Subdocuments collection that represents all the subdocuments in the specified range.

SynonymInfo

Returns a SynonymInfo object that contains information from the thesaurus on synonyms, antonyms, or related words and expressions for the specified word or phrase.

Tables

Returns a Tables collection that represents all the tables in the specified range.

TableStyle

Returns a Object that represents the style used to format a table. Read-only.

Text

Returns or sets the text in the specified range.

TextRetrievalMode

Returns a TextRetrievalMode object that controls how text is retrieved from the specified range.

TextVisibleOnScreen

Returns an Integer (int in C#) that indicates whether the text in the specified range is visible on the screen. Read-only.

TopLevelTables

Returns a Tables collection that represents the tables at the outermost nesting level in the current range.

TwoLinesInOne

Returns or sets whether Microsoft Word sets two lines of text in one and specifies the characters that enclose the text, if any.

Underline

Returns or sets the type of underline applied to the range.

Updates

Gets a CoAuthUpdates collection object that represents all the available updates in the range.

WordOpenXML

Returns a String that represents the XML contained within the range in the Microsoft Office Word Open XML format. Read-only.

Words

Returns a Words collection that represents all the words in a range.

XML[Boolean]

Returns a String that represents the XML text in the specified object.

XMLNodes

This object, member, or enumeration is deprecated and is not intended to be used in your code.

XMLParentNode

This object, member, or enumeration is deprecated and is not intended to be used in your code.

Methods

AutoFormat()

Automatically formats a range.

Calculate()

Calculates a mathematical expression within a range.

CheckGrammar()

Begins a spelling and grammar check for the specified range.

CheckSpelling(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

Begins a spelling check for the specified range.

CheckSynonyms()

Displays the Thesaurus dialog box, which lists alternative word choices, or synonyms, for the text in the specified range.

Collapse(Object)

Collapses a range to the starting or ending position.

ComputeStatistics(WdStatistic)

Returns a statistic based on the contents of the specified range.

ConvertHangulAndHanja(Object, Object, Object, Object, Object)

Converts the specified range from Hangul to Hanja or vice versa.

ConvertToTable(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

Converts text within a range or selection to a table.

ConvertToTableOld(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

Reserved for internal use.

Copy()

Copies the specified object to the Clipboard.

CopyAsPicture()

The CopyAsPicture method works the same way as the Copy() method.

CreatePublisher(Object, Object, Object, Object)

Reserved for internal use.This member is for Macintosh only and should not be used.

Cut()

Removes the specified object from the document and places it on the Clipboard.

Delete(Object, Object)

Deletes the specified number of characters or words.

DetectLanguage()

Analyzes the specified text to determine the language that it is written in.

EndOf(Object, Object)

Moves or extends the ending character position of a range or selection to the end of the nearest specified text unit.

Expand(Object)

Expands the specified range.

ExportAsFixedFormat(String, WdExportFormat, Boolean, WdExportOptimizeFor, Boolean, WdExportItem, Boolean, Boolean, WdExportCreateBookmarks, Boolean, Boolean, Boolean, Object)

Saves a portion of a document as PDF or XPS format.

ExportFragment(String, WdSaveFormat)

Exports the selected range into a document for use as a document fragment.

GetSpellingSuggestions(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

Returns a SpellingSuggestions collection that represents the words suggested as spelling replacements for the first word in the specified range.

GoTo(Object, Object, Object, Object)

Returns a Range object that represents the start position of the specified item, such as a page, bookmark, or field.

GoToEditableRange(Object)

Returns a Range object that represents an area of a document that can be modified by the specified user or group of users.

GoToNext(WdGoToItem)

Returns a Range object that refers to the start position of the next item or location specified by the What argument.

GoToPrevious(WdGoToItem)

Returns a Range object that refers to the start position of the previous item or location specified by the What argument.

ImportFragment(String, Boolean)

Imports a document fragment into the document at the specified range.

InRange(Range)

Determines if the range to which the method is applied is contained in the specified range.

InsertAfter(String)

Inserts the specified text at the end of a range or selection.

InsertAlignmentTab(Int32, Int32)

Inserts an absolute tab that is always positioned in the same spot, relative to either the margins or indents.

InsertAutoText()

Attempts to match the text in the specified range or the text surrounding the range with an existing AutoText entry name.

InsertBefore(String)

Inserts the specified text before the specified range.

InsertBreak(Object)

Inserts a page, column, or section break.

InsertCaption(Object, Object, Object, Object, Object)

Inserts a caption immediately preceding or following the specified range.

InsertCaptionXP(Object, Object, Object, Object)

Reserved for internal use.

InsertCrossReference_2002(Object, WdReferenceKind, Object, Object, Object)

Reserved for internal use.

InsertCrossReference(Object, WdReferenceKind, Object, Object, Object, Object, Object)

Inserts a cross-reference to a heading, bookmark, footnote, or endnote, or to an item for which a caption label is defined (for example, an equation, figure, or table).

InsertDatabase(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

Retrieves data from a data source (for example, a separate Microsoft Word document, a Microsoft Excel worksheet, or a Microsoft Access database) and inserts the data as a table in place of the specified range.

InsertDateTime(Object, Object, Object, Object, Object)

Inserts the current date or time, or both, either as text or as a TIME field.

InsertDateTimeOld(Object, Object, Object)

Reserved for internal use.

InsertFile(String, Object, Object, Object, Object)

Inserts all or part of the specified file.

InsertParagraph()

Replaces the specified range with a new paragraph.

InsertParagraphAfter()

Inserts a paragraph mark after a range.

InsertParagraphBefore()

Inserts a new paragraph before the specified range.

InsertSymbol(Int32, Object, Object, Object)

Inserts a symbol in place of the specified range.

InsertXML(String, Object)

Inserts the specified XML text into the specified range or selection.

InStory(Range)

Determines if the selection or range to which this method is applied is in the same story as the range specified by the Range argument.

IsEqual(Range)

Determines if the range to which this method is applied is equal to the range specified by the Range argument.

LookupNameProperties()

Looks up a name in the global address book list and displays the Properties dialog box, which includes information about the specified name.

ModifyEnclosure(Object, Object, Object)

Adds, modifies, or removes an enclosure around the specified character or characters.

Move(Object, Object)

Collapses the specified range or selection to its start or end position and then moves the collapsed object by the specified number of units.

MoveEnd(Object, Object)

Moves the ending character position of a range.

MoveEndUntil(Object, Object)

Moves the end position of the specified range or selection until any of the specified characters are found in the document.

MoveEndWhile(Object, Object)

Moves the ending character position of a range while any of the specified characters are found in the document.

MoveStart(Object, Object)

Moves the start position of the specified range.

MoveStartUntil(Object, Object)

Moves the start position of the specified range or selection until one of the specified characters is found in the document.

MoveStartWhile(Object, Object)

Moves the start position of the specified range while any of the specified characters are found in the document.

MoveUntil(Object, Object)

Moves the specified range until one of the specified characters is found in the document.

MoveWhile(Object, Object)

Moves the specified range while any of the specified characters are found in the document.

Next(Object, Object)

Returns a Range object that represents the specified unit relative to the specified range.

NextSubdocument()

Moves the range to the next subdocument.

Paste()

Inserts the contents of the Clipboard at the specified range.

PasteAndFormat(WdRecoveryType)

Pastes the selected table cells and formats them as specified.

PasteAppendTable()

Merges pasted cells into an existing table by inserting the pasted rows between the selected rows.

PasteAsNestedTable()

Pastes a cell or group of cells as a nested table into the selected range.

PasteExcelTable(Boolean, Boolean, Boolean)

Pastes and formats a Microsoft Excel table.

PasteSpecial(Object, Object, Object, Object, Object, Object, Object)

Inserts the contents of the Clipboard.

PhoneticGuide(String, WdPhoneticGuideAlignmentType, Int32, Int32, String)

Adds phonetic guides to the specified range.

Previous(Object, Object)

Returns a Range object relative to the specified selection or range.

PreviousSubdocument()

Moves the range or selection to the previous subdocument. If there isn't another subdocument, an error occurs.

Relocate(Int32)

In outline view, moves the paragraphs within the specified range after the next visible paragraph or before the previous visible paragraph.

Select()

Selects the specified object.

SetListLevel(Int16)

Sets the list level for one or more items in a numbered list.

SetRange(Int32, Int32)

Sets the starting and ending character positions for the range.

Sort(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

Sorts the paragraphs in the specified range.

SortAscending()

Sorts paragraphs or table rows in ascending alphanumeric order.

SortByHeadings(Object, Object, Object, Object, Object, Object, Object, Object, Object)

Sorts the headings in the specified range.

SortDescending()

Sorts paragraphs or table rows in descending alphanumeric order.

SortOld(Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object)

Reserved for internal use.

StartOf(Object, Object)

Moves or extends the start position of the specified range or selection to the beginning of the nearest specified text unit.

SubscribeTo(String, Object)

Reserved for internal use.This member is for Macintosh only and should not be used.

TCSCConverter(WdTCSCConverterDirection, Boolean, Boolean)

Converts the specified range from Traditional Chinese to Simplified Chinese or vice versa.

WholeStory()

Expands a range to include the entire story.

Applies to