Word.Selection class
Represents a selected range or the insertion point in a Word document.
- Extends
Remarks
[ API set: WordApiDesktop 1.4 ]
Note: Range objects share many of the same methods and properties as Selection objects. Using Range objects is preferable for manipulating a document when there isn't a reason to physically change the current selection.
Properties
| borders | Returns a |
| characters | Returns a |
| comments | Returns a |
| context | The request context associated with the object. This connects the add-in's process to the Office host application's process. |
| end | Specifies the ending character position of the selection. |
| fields | Returns a |
| fit |
Specifies the width in which Word fits the text in the current selection. |
| font | Returns the |
| formatted |
Specifies a |
| has |
Returns whether the spelling and grammar checker ignores the selected text. If the selected text contains a mix of proofed and un-proofed content, this API returns |
| is |
Returns whether the selection in the specified window or pane is active. |
| is |
Specifies whether column selection mode is active. |
| is |
Returns whether the selection is at the end-of-row mark in a table. |
| is |
Specifies whether Extend mode is active. |
| is |
Returns whether the insertion point is at the end of a line. |
| is |
Specifies whether the beginning of the selection is active. |
| language |
Specifies whether Word has detected the language of the selected text. |
| language |
Returns the language for the selection. |
| language |
Returns the East Asian language for the selection. |
| language |
Returns the language for the selection that isn't classified as an East Asian language. |
| orientation | Specifies the orientation of text in the selection. |
| paragraphs | Returns a |
| range | Returns the |
| sections | Returns the |
| sentences | Returns the |
| shading | Returns the |
| start | Specifies the starting character position of the selection. |
| story |
Returns the number of characters in the story that contains the selection. |
| story |
Returns the story type for the selection. |
| tables | Returns the |
| text | Specifies the text in the selection. |
| top |
Returns the tables at the outermost nesting level in the current selection. |
| type | Returns the selection type. |
| words | Returns the |
Methods
| calculate() | Calculates the first mathematical expression within the selection. |
| cancel |
Cancels a mode such as extend or column select. This is equivalent to pressing the Esc key. |
| clear |
Removes character formatting applied through character styles. |
| clear |
Removes character and paragraph formatting from the selection. |
| clear |
Removes manually applied character formatting from the selected text. |
| clear |
Removes manually applied paragraph formatting from the selected text. |
| clear |
Removes all paragraph formatting from the selected text. |
| clear |
Removes paragraph formatting applied through paragraph styles. |
| collapse(direction) | Collapses the selection to the starting or ending position. |
| collapse(direction) | Collapses the selection to the starting or ending position. |
| convert |
Converts text within a range to a table. |
| copy |
Copies the selection to the Clipboard as a picture. |
| copy |
Copies the character formatting of the first character in the selected text. |
| copy |
Copies the selection to the Clipboard. |
| create |
Adds a default-sized text box around the selection. |
| cut() | Removes the selected content from the document and moves it to the Clipboard. |
| delete(options) | Deletes the specified number of characters or words. |
| detect |
Analyzes the selected text to determine the language that it's written in. |
| expand(unit) | Expands the selection. |
| expand(unit) | Expands the selection. |
| expand |
Expands the selection to include the entire story. |
| extend(character) | Turns on extend mode, or if extend mode is already on, extends the selection to the next larger unit of text. |
| extend(character) | Turns on extend mode, or if extend mode is already on, extends the selection to the next larger unit of text. |
| get |
Returns a |
| get |
Returns a |
| go |
Returns a |
| go |
Returns a |
| go |
Returns a |
| go |
Returns a |
| go |
Returns a |
| insert |
Inserts the specified text at the end of the range or selection. |
| insert |
Inserts the specified text before the selection. |
| insert |
Adds cells to an existing table. |
| insert |
Adds cells to an existing table. |
| insert |
Inserts columns to the left of the column that contains the selection. |
| insert |
Inserts columns to the right of the current selection. |
| insert |
Inserts the current date or time, or both, either as text or as a TIME field. |
| insert |
Inserts a Formula field at the selection. |
| insert |
Inserts a new page at the position of the insertion point. |
| insert |
Inserts a paragraph mark after the selection. |
| insert |
Inserts a new paragraph before the selection or range. |
| insert |
Inserts a special hidden paragraph mark that allows Word to join paragraphs formatted using different paragraph styles. |
| insert |
Inserts rows above the current selection. |
| insert |
Inserts rows below the current selection. |
| insert |
Inserts a symbol in place of the specified selection. |
| insert |
Inserts the specified text. |
| insert |
Inserts the specified XML into the document at the cursor, replacing any selected text. |
| is |
Returns whether the selection is equal to the specified range. |
| is |
Returns |
| is |
Returns whether the selection is in the same story as the specified range. |
| load(options) | Queues up a command to load the specified properties of the object. You must call |
| load(property |
Queues up a command to load the specified properties of the object. You must call |
| load(property |
Queues up a command to load the specified properties of the object. You must call |
| move(options) | Collapses the selection to its start or end position and then moves the collapsed object by the specified number of units. |
| move |
Moves the selection down. |
| move |
Moves the ending character position of the range or selection. |
| move |
Moves the end position of the selection until any of the specified characters are found in the document. |
| move |
Moves the ending character position of the selection while any of the specified characters are found in the document. |
| move |
Moves the selection to the left. |
| move |
Moves the selection to the right. |
| move |
Moves the start position of the selection. |
| move |
Moves the start position of the selection until one of the specified characters is found in the document. |
| move |
Moves the start position of the selection while any of the specified characters are found in the document. |
| move |
Moves the selection until one of the specified characters is found in the document. |
| move |
Moves the selection up. |
| move |
Moves the selection while any of the specified characters are found in the document. |
| next |
Selects the next field. |
| next |
Moves the selection to the next subdocument. |
| paste |
Pastes the content from clipboard and formats them as specified. |
| paste |
Pastes the content from clipboard and formats them as specified. |
| paste |
Pastes and formats a Microsoft Excel table. |
| paste |
Applies formatting copied with the |
| paste |
Merges pasted cells into an existing table by inserting the pasted rows between the selected rows. |
| paste |
Pastes a cell or group of cells as a nested table into the selection. |
| previous |
Selects and returns the previous field. |
| previous |
Moves the selection to the previous subdocument. |
| replace |
Replaces the selection with a new paragraph. |
| select() | Selects the current text. |
| select |
Selects the entire cell containing the current selection when the selection is in a table. |
| select |
Selects the column that contains the insertion point, or selects all columns that contain the selection when the selection is in a table. |
| select |
Extends the selection forward until text with a different paragraph alignment is encountered. |
| select |
Extends the selection forward until text with a different color is encountered. |
| select |
Extends the selection forward until text in a different font or font size is encountered. |
| select |
Extends the selection forward until text with different left or right paragraph indents is encountered. |
| select |
Extends the selection forward until a paragraph with different line spacing is encountered. |
| select |
Extends the selection forward until a paragraph with different tab stops is encountered. |
| select |
Selects the row that contains the insertion point, or selects all rows that contain the selection when the selection is in a table. |
| set |
Sets the starting and ending character positions for the selection. Character position values start at the beginning of the story, with the first value being 0. All characters are counted, including nonprinting characters. Hidden characters are counted even if they're not displayed. |
| shrink() | Shrinks the selection to the next smaller unit of text. The unit progression for this method is as follows: entire document, section, paragraph, sentence, word, insertion point. |
| shrink |
Cancels the selection of all but the most recently selected text when the current selection contains multiple, unconnected selections. |
| split |
Inserts an empty paragraph above the first row in the selection. If the selection isn't in the first row of the table, the table is split into two tables. If the selection isn't in a table, an error occurs. |
| toggle |
Switches the selection between a Unicode character and its corresponding hexadecimal value. |
| toJSON() | Overrides the JavaScript |
| track() | Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you're using this object across |
| type |
Deletes the character preceding the selection (if collapsed) or the insertion point. |
| untrack() | Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You'll need to call |
Property Details
borders
Returns a BorderUniversalCollection object that represents all the borders for the objects in the selection.
readonly borders: Word.BorderUniversalCollection;
Property Value
Remarks
characters
Returns a RangeScopedCollection object that represents each character in the selection.
readonly characters: Word.RangeScopedCollection;
Property Value
Remarks
comments
Returns a CommentCollection object that represents all the comments in the selection.
readonly comments: Word.CommentCollection;
Property Value
Remarks
context
The request context associated with the object. This connects the add-in's process to the Office host application's process.
context: RequestContext;
Property Value
end
Specifies the ending character position of the selection.
end: number;
Property Value
number
Remarks
fields
Returns a FieldCollection object that represents all the fields in the selection.
readonly fields: Word.FieldCollection;
Property Value
Remarks
fitTextWidth
Specifies the width in which Word fits the text in the current selection.
fitTextWidth: number;
Property Value
number
Remarks
font
Returns the Font object that represents the character formatting of the selection.
readonly font: Word.Font;
Property Value
Remarks
formattedText
Specifies a Range object that includes the formatted text in the range or selection.
formattedText: Word.Range;
Property Value
Remarks
hasNoProofing
Returns whether the spelling and grammar checker ignores the selected text. If the selected text contains a mix of proofed and un-proofed content, this API returns null.
readonly hasNoProofing: boolean;
Property Value
boolean
Remarks
isActive
Returns whether the selection in the specified window or pane is active.
readonly isActive: boolean;
Property Value
boolean
Remarks
isColumnSelectModeActive
Specifies whether column selection mode is active.
isColumnSelectModeActive: boolean;
Property Value
boolean
Remarks
isEndOfRowMark
Returns whether the selection is at the end-of-row mark in a table.
readonly isEndOfRowMark: boolean;
Property Value
boolean
Remarks
isExtendModeActive
Specifies whether Extend mode is active.
isExtendModeActive: boolean;
Property Value
boolean
Remarks
isInsertionPointAtEndOfLine
Returns whether the insertion point is at the end of a line.
readonly isInsertionPointAtEndOfLine: boolean;
Property Value
boolean
Remarks
isStartActive
Specifies whether the beginning of the selection is active.
isStartActive: boolean;
Property Value
boolean
Remarks
languageDetected
Specifies whether Word has detected the language of the selected text.
languageDetected: boolean;
Property Value
boolean
Remarks
languageId
Returns the language for the selection.
readonly languageId: Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu";
Property Value
Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu"
Remarks
languageIdFarEast
Returns the East Asian language for the selection.
readonly languageIdFarEast: Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu";
Property Value
Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu"
Remarks
languageIdOther
Returns the language for the selection that isn't classified as an East Asian language.
readonly languageIdOther: Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu";
Property Value
Word.LanguageId | "Afrikaans" | "Albanian" | "Amharic" | "Arabic" | "ArabicAlgeria" | "ArabicBahrain" | "ArabicEgypt" | "ArabicIraq" | "ArabicJordan" | "ArabicKuwait" | "ArabicLebanon" | "ArabicLibya" | "ArabicMorocco" | "ArabicOman" | "ArabicQatar" | "ArabicSyria" | "ArabicTunisia" | "ArabicUAE" | "ArabicYemen" | "Armenian" | "Assamese" | "AzeriCyrillic" | "AzeriLatin" | "Basque" | "BelgianDutch" | "BelgianFrench" | "Bengali" | "Bulgarian" | "Burmese" | "Belarusian" | "Catalan" | "Cherokee" | "ChineseHongKongSAR" | "ChineseMacaoSAR" | "ChineseSingapore" | "Croatian" | "Czech" | "Danish" | "Divehi" | "Dutch" | "Edo" | "EnglishAUS" | "EnglishBelize" | "EnglishCanadian" | "EnglishCaribbean" | "EnglishIndonesia" | "EnglishIreland" | "EnglishJamaica" | "EnglishNewZealand" | "EnglishPhilippines" | "EnglishSouthAfrica" | "EnglishTrinidadTobago" | "EnglishUK" | "EnglishUS" | "EnglishZimbabwe" | "Estonian" | "Faeroese" | "Filipino" | "Finnish" | "French" | "FrenchCameroon" | "FrenchCanadian" | "FrenchCongoDRC" | "FrenchCotedIvoire" | "FrenchHaiti" | "FrenchLuxembourg" | "FrenchMali" | "FrenchMonaco" | "FrenchMorocco" | "FrenchReunion" | "FrenchSenegal" | "FrenchWestIndies" | "FrisianNetherlands" | "Fulfulde" | "GaelicIreland" | "GaelicScotland" | "Galician" | "Georgian" | "German" | "GermanAustria" | "GermanLiechtenstein" | "GermanLuxembourg" | "Greek" | "Guarani" | "Gujarati" | "Hausa" | "Hawaiian" | "Hebrew" | "Hindi" | "Hungarian" | "Ibibio" | "Icelandic" | "Igbo" | "Indonesian" | "Inuktitut" | "Italian" | "Japanese" | "Kannada" | "Kanuri" | "Kashmiri" | "Kazakh" | "Khmer" | "Kirghiz" | "Konkani" | "Korean" | "Kyrgyz" | "LanguageNone" | "Lao" | "Latin" | "Latvian" | "Lithuanian" | "MacedonianFYROM" | "Malayalam" | "MalayBruneiDarussalam" | "Malaysian" | "Maltese" | "Manipuri" | "Marathi" | "MexicanSpanish" | "Mongolian" | "Nepali" | "NoProofing" | "NorwegianBokmol" | "NorwegianNynorsk" | "Oriya" | "Oromo" | "Pashto" | "Persian" | "Polish" | "Portuguese" | "PortugueseBrazil" | "Punjabi" | "RhaetoRomanic" | "Romanian" | "RomanianMoldova" | "Russian" | "RussianMoldova" | "SamiLappish" | "Sanskrit" | "SerbianCyrillic" | "SerbianLatin" | "Sesotho" | "SimplifiedChinese" | "Sindhi" | "SindhiPakistan" | "Sinhalese" | "Slovak" | "Slovenian" | "Somali" | "Sorbian" | "Spanish" | "SpanishArgentina" | "SpanishBolivia" | "SpanishChile" | "SpanishColombia" | "SpanishCostaRica" | "SpanishDominicanRepublic" | "SpanishEcuador" | "SpanishElSalvador" | "SpanishGuatemala" | "SpanishHonduras" | "SpanishModernSort" | "SpanishNicaragua" | "SpanishPanama" | "SpanishParaguay" | "SpanishPeru" | "SpanishPuertoRico" | "SpanishUruguay" | "SpanishVenezuela" | "Sutu" | "Swahili" | "Swedish" | "SwedishFinland" | "SwissFrench" | "SwissGerman" | "SwissItalian" | "Syriac" | "Tajik" | "Tamazight" | "TamazightLatin" | "Tamil" | "Tatar" | "Telugu" | "Thai" | "Tibetan" | "TigrignaEritrea" | "TigrignaEthiopic" | "TraditionalChinese" | "Tsonga" | "Tswana" | "Turkish" | "Turkmen" | "Ukrainian" | "Urdu" | "UzbekCyrillic" | "UzbekLatin" | "Venda" | "Vietnamese" | "Welsh" | "Xhosa" | "Yi" | "Yiddish" | "Yoruba" | "Zulu"
Remarks
orientation
Specifies the orientation of text in the selection.
orientation: Word.TextOrientation | "Horizontal" | "Upward" | "Downward" | "VerticalFarEast" | "HorizontalRotatedFarEast" | "Vertical";
Property Value
Word.TextOrientation | "Horizontal" | "Upward" | "Downward" | "VerticalFarEast" | "HorizontalRotatedFarEast" | "Vertical"
Remarks
paragraphs
Returns a ParagraphCollection object that represents all the paragraphs in the selection.
readonly paragraphs: Word.ParagraphCollection;
Property Value
Remarks
range
Returns the Range object for the portion of the document contained in the selection.
readonly range: Word.Range;
Property Value
Remarks
sections
Returns the SectionCollection object in the selection.
readonly sections: Word.SectionCollection;
Property Value
Remarks
sentences
Returns the RangeScopedCollection object for each sentence in the selection.
readonly sentences: Word.RangeScopedCollection;
Property Value
Remarks
shading
Returns the ShadingUniversal object for the shading formatting for the selection.
readonly shading: Word.ShadingUniversal;
Property Value
Remarks
start
Specifies the starting character position of the selection.
start: number;
Property Value
number
Remarks
storyLength
Returns the number of characters in the story that contains the selection.
readonly storyLength: number;
Property Value
number
Remarks
storyType
Returns the story type for the selection.
readonly storyType: Word.StoryType | "MainText" | "Footnotes" | "Endnotes" | "Comments" | "TextFrame" | "EvenPagesHeader" | "PrimaryHeader" | "EvenPagesFooter" | "PrimaryFooter" | "FirstPageHeader" | "FirstPageFooter" | "FootnoteSeparator" | "FootnoteContinuationSeparator" | "FootnoteContinuationNotice" | "EndnoteSeparator" | "EndnoteContinuationSeparator" | "EndnoteContinuationNotice";
Property Value
Word.StoryType | "MainText" | "Footnotes" | "Endnotes" | "Comments" | "TextFrame" | "EvenPagesHeader" | "PrimaryHeader" | "EvenPagesFooter" | "PrimaryFooter" | "FirstPageHeader" | "FirstPageFooter" | "FootnoteSeparator" | "FootnoteContinuationSeparator" | "FootnoteContinuationNotice" | "EndnoteSeparator" | "EndnoteContinuationSeparator" | "EndnoteContinuationNotice"
Remarks
tables
Returns the TableCollection object in the selection.
readonly tables: Word.TableCollection;
Property Value
Remarks
text
Specifies the text in the selection.
text: string;
Property Value
string
Remarks
topLevelTables
Returns the tables at the outermost nesting level in the current selection.
readonly topLevelTables: Word.TableCollection;
Property Value
Remarks
type
Returns the selection type.
readonly type: Word.SelectionType | "NoSelection" | "InsertionPoint" | "Normal" | "Frame" | "Column" | "Row" | "Block" | "InlineShape" | "SelectionShape";
Property Value
Word.SelectionType | "NoSelection" | "InsertionPoint" | "Normal" | "Frame" | "Column" | "Row" | "Block" | "InlineShape" | "SelectionShape"
Remarks
words
Returns the RangeScopedCollection object that represents each word in the selection.
readonly words: Word.RangeScopedCollection;
Property Value
Remarks
Method Details
calculate()
Calculates the first mathematical expression within the selection.
calculate(): OfficeExtension.ClientResult<number>;
Returns
OfficeExtension.ClientResult<number>
The result of the calculation.
Remarks
cancelMode()
Cancels a mode such as extend or column select. This is equivalent to pressing the Esc key.
cancelMode(): void;
Returns
void
Remarks
clearCharacterStyleFormatting()
Removes character formatting applied through character styles.
clearCharacterStyleFormatting(): void;
Returns
void
Remarks
clearFormatting()
Removes character and paragraph formatting from the selection.
clearFormatting(): void;
Returns
void
Remarks
clearManualCharacterFormatting()
Removes manually applied character formatting from the selected text.
clearManualCharacterFormatting(): void;
Returns
void
Remarks
clearManualParagraphFormatting()
Removes manually applied paragraph formatting from the selected text.
clearManualParagraphFormatting(): void;
Returns
void
Remarks
clearParagraphFormatting()
Removes all paragraph formatting from the selected text.
clearParagraphFormatting(): void;
Returns
void
Remarks
clearParagraphStyle()
Removes paragraph formatting applied through paragraph styles.
clearParagraphStyle(): void;
Returns
void
Remarks
collapse(direction)
Collapses the selection to the starting or ending position.
collapse(direction?: Word.CollapseDirection): void;
Parameters
- direction
- Word.CollapseDirection
Optional. Direction to collapse.
Returns
void
Remarks
collapse(direction)
Collapses the selection to the starting or ending position.
collapse(direction?: "Start" | "End"): void;
Parameters
- direction
-
"Start" | "End"
Optional. Direction to collapse.
Returns
void
Remarks
convertToTable(options)
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Converts text within a range to a table.
convertToTable(options?: Word.SelectionConvertToTableOptions): Word.Table;
Parameters
Optional. Options for converting text to a table.
Returns
A Table object that represents the newly created table.
Remarks
copyAsPictureToClipboard()
Copies the selection to the Clipboard as a picture.
copyAsPictureToClipboard(): void;
Returns
void
Remarks
copyFormat()
Copies the character formatting of the first character in the selected text.
copyFormat(): void;
Returns
void
Remarks
copyToClipboard()
Copies the selection to the Clipboard.
copyToClipboard(): void;
Returns
void
Remarks
createTextBox()
Adds a default-sized text box around the selection.
createTextBox(): void;
Returns
void
Remarks
cut()
Removes the selected content from the document and moves it to the Clipboard.
cut(): void;
Returns
void
Remarks
delete(options)
Deletes the specified number of characters or words.
delete(options?: Word.SelectionDeleteOptions): OfficeExtension.ClientResult<number>;
Parameters
- options
- Word.SelectionDeleteOptions
Optional. Options for deleting text.
Returns
OfficeExtension.ClientResult<number>
The number of characters deleted.
Remarks
detectLanguage()
Analyzes the selected text to determine the language that it's written in.
detectLanguage(): void;
Returns
void
Remarks
expand(unit)
Expands the selection.
expand(unit?: Word.OperationUnit): OfficeExtension.ClientResult<number>;
Parameters
- unit
- Word.OperationUnit
Optional. The unit to expand.
Returns
OfficeExtension.ClientResult<number>
The number of characters added to the range or selection.
Remarks
expand(unit)
Expands the selection.
expand(unit?: "Character" | "Word" | "Sentence" | "Paragraph" | "Line" | "Story" | "Screen" | "Section" | "Column" | "Row" | "Window" | "Cell" | "CharacterFormat" | "ParagraphFormat" | "Table" | "Item"): OfficeExtension.ClientResult<number>;
Parameters
- unit
-
"Character" | "Word" | "Sentence" | "Paragraph" | "Line" | "Story" | "Screen" | "Section" | "Column" | "Row" | "Window" | "Cell" | "CharacterFormat" | "ParagraphFormat" | "Table" | "Item"
Optional. The unit to expand.
Returns
OfficeExtension.ClientResult<number>
The number of characters added to the range or selection.
Remarks
expandToWholeStory()
Expands the selection to include the entire story.
expandToWholeStory(): void;
Returns
void
Remarks
extend(character)
Turns on extend mode, or if extend mode is already on, extends the selection to the next larger unit of text.
extend(character?: Word.OperationUnit): void;
Parameters
- character
- Word.OperationUnit
Optional. The character through which the selection is extended. This argument is case-sensitive and must evaluate to a string or an error occurs. Also, if the value of this argument is longer than a single character, Microsoft Word ignores the command entirely.
Returns
void
Remarks
extend(character)
Turns on extend mode, or if extend mode is already on, extends the selection to the next larger unit of text.
extend(character?: "Character" | "Word" | "Sentence" | "Paragraph" | "Line" | "Story" | "Screen" | "Section" | "Column" | "Row" | "Window" | "Cell" | "CharacterFormat" | "ParagraphFormat" | "Table" | "Item"): void;
Parameters
- character
-
"Character" | "Word" | "Sentence" | "Paragraph" | "Line" | "Story" | "Screen" | "Section" | "Column" | "Row" | "Window" | "Cell" | "CharacterFormat" | "ParagraphFormat" | "Table" | "Item"
Optional. The character through which the selection is extended. This argument is case-sensitive and must evaluate to a string or an error occurs. Also, if the value of this argument is longer than a single character, Microsoft Word ignores the command entirely.
Returns
void
Remarks
getNextRange(options)
Returns a Range object that represents the next unit relative to the selection.
getNextRange(options?: Word.SelectionNextOptions): Word.Range;
Parameters
- options
- Word.SelectionNextOptions
Optional. Options for the next operation.
Returns
A Range object that represents the next unit relative to the selection.
Remarks
getPreviousRange(options)
Returns a Range object that represents the previous unit relative to the selection.
getPreviousRange(options?: Word.SelectionPreviousOptions): Word.Range;
Parameters
- options
- Word.SelectionPreviousOptions
Optional. Options for the previous operation.
Returns
A Range object that represents the previous unit relative to the selection.
Remarks
goTo(options)
Note
This API is provided as a preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Returns a Range object that represents the area specified by the options and moves the insertion point to the character position immediately preceding the specified item.
goTo(options?: Word.GoToOptions): Word.Range;
Parameters
- options
- Word.GoToOptions
Optional. Options for the goTo operation.
Returns
A Range object that is now selected.
Remarks
goToNext(what)
Returns a Range object that refers to the start position of the next item or location specified by the what argument and moves the selection to the specified item.
goToNext(what: Word.GoToItem): Word.Range;
Parameters
- what
- Word.GoToItem
The item type to go to.
Returns
A Range object that refers to the start position of the next item or location specified by the what argument.
Remarks
goToNext(what)
Returns a Range object that refers to the start position of the next item or location specified by the what argument and moves the selection to the specified item.
goToNext(what: "Bookmark" | "Comment" | "Endnote" | "Field" | "Footnote" | "Graphic" | "Heading" | "Line" | "Page" | "Section" | "Table" | "EmbeddedObject" | "Equation" | "Percent" | "SpellingError" | "GrammaticalError" | "ProofreadingError"): Word.Range;
Parameters
- what
-
"Bookmark" | "Comment" | "Endnote" | "Field" | "Footnote" | "Graphic" | "Heading" | "Line" | "Page" | "Section" | "Table" | "EmbeddedObject" | "Equation" | "Percent" | "SpellingError" | "GrammaticalError" | "ProofreadingError"
The item type to go to.
Returns
A Range object that refers to the start position of the next item or location specified by the what argument.
Remarks
goToPrevious(what)
Returns a Range object that refers to the start position of the previous item or location specified by the what argument and moves the selection to the specified item.
goToPrevious(what: Word.GoToItem): Word.Range;
Parameters
- what
- Word.GoToItem
The item type to go to.
Returns
A Range object that refers to the start position of the previous item or location specified by the what argument.
Remarks
goToPrevious(what)
Returns a Range object that refers to the start position of the previous item or location specified by the what argument and moves the selection to the specified item.
goToPrevious(what: "Bookmark" | "Comment" | "Endnote" | "Field" | "Footnote" | "Graphic" | "Heading" | "Line" | "Page" | "Section" | "Table" | "EmbeddedObject" | "Equation" | "Percent" | "SpellingError" | "GrammaticalError" | "ProofreadingError"): Word.Range;
Parameters
- what
-
"Bookmark" | "Comment" | "Endnote" | "Field" | "Footnote" | "Graphic" | "Heading" | "Line" | "Page" | "Section" | "Table" | "EmbeddedObject" | "Equation" | "Percent" | "SpellingError" | "GrammaticalError" | "ProofreadingError"
The item type to go to.
Returns
A Range object that refers to the start position of the previous item or location specified by the what argument.
Remarks
insertAfter(text)
Inserts the specified text at the end of the range or selection.
insertAfter(text: string): void;
Parameters
- text
-
string
Text to insert.
Returns
void
Remarks
insertBefore(text)
Inserts the specified text before the selection.
insertBefore(text: string): void;
Parameters
- text
-
string
Text to insert.
Returns
void
Remarks
insertCells(shiftCells)
Adds cells to an existing table.
insertCells(shiftCells?: Word.TableCellInsertionLocation): void;
Parameters
- shiftCells
- Word.TableCellInsertionLocation
Optional. Specifies how to insert the cells into the existing columns and rows of the table. The default value is shiftDown.
Returns
void
Remarks
insertCells(shiftCells)
Adds cells to an existing table.
insertCells(shiftCells?: "ShiftRight" | "ShiftDown" | "ShiftRowDown" | "ShiftColumnRight"): void;
Parameters
- shiftCells
-
"ShiftRight" | "ShiftDown" | "ShiftRowDown" | "ShiftColumnRight"
Optional. Specifies how to insert the cells into the existing columns and rows of the table. The default value is shiftDown.
Returns
void
Remarks
insertColumnsLeft()
Inserts columns to the left of the column that contains the selection.
insertColumnsLeft(): void;
Returns
void
Remarks
insertColumnsRight()
Inserts columns to the right of the current selection.
insertColumnsRight(): void;
Returns
void
Remarks
insertDateTime(options)
Inserts the current date or time, or both, either as text or as a TIME field.
insertDateTime(options?: Word.SelectionInsertDateTimeOptions): void;
Parameters
Optional. Options for inserting the date or time.
Returns
void
Remarks
insertFormula(options)
Inserts a Formula field at the selection.
insertFormula(options?: Word.SelectionInsertFormulaOptions): void;
Parameters
Optional. Options for inserting the formula.
Returns
void
Remarks
insertNewPage()
Inserts a new page at the position of the insertion point.
insertNewPage(): void;
Returns
void
Remarks
insertParagraphAfter()
Inserts a paragraph mark after the selection.
insertParagraphAfter(): void;
Returns
void
Remarks
insertParagraphBefore()
Inserts a new paragraph before the selection or range.
insertParagraphBefore(): void;
Returns
void
Remarks
insertParagraphStyleSeparator()
Inserts a special hidden paragraph mark that allows Word to join paragraphs formatted using different paragraph styles.
insertParagraphStyleSeparator(): void;
Returns
void
Remarks
insertRowsAbove(numRows)
Inserts rows above the current selection.
insertRowsAbove(numRows: number): void;
Parameters
- numRows
-
number
Optional. Number of rows to insert.
Returns
void
Remarks
insertRowsBelow(numRows)
Inserts rows below the current selection.
insertRowsBelow(numRows: number): void;
Parameters
- numRows
-
number
Optional. Number of rows to insert.
Returns
void
Remarks
insertSymbol(characterNumber, options)
Inserts a symbol in place of the specified selection.
insertSymbol(characterNumber: number, options?: Word.SelectionInsertSymbolOptions): void;
Parameters
- characterNumber
-
number
The character number of the symbol.
Optional. Options for inserting the symbol.
Returns
void
Remarks
insertText(Text)
Inserts the specified text.
insertText(Text: string): void;
Parameters
- Text
-
string
The text to insert.
Returns
void
Remarks
insertXml(xml, transform)
Inserts the specified XML into the document at the cursor, replacing any selected text.
insertXml(xml: string, transform?: string): void;
Parameters
- xml
-
string
The XML string to insert.
- transform
-
string
Optional. XSL transform to apply.
Returns
void
Remarks
isEqual(range)
Returns whether the selection is equal to the specified range.
isEqual(range: Word.Range): OfficeExtension.ClientResult<boolean>;
Parameters
- range
- Word.Range
The range to compare.
Returns
OfficeExtension.ClientResult<boolean>
true if the selection is equal to the specified range.
Remarks
isInRange(range)
Returns true if the selection is contained within the specified range.
isInRange(range: Word.Range): OfficeExtension.ClientResult<boolean>;
Parameters
- range
- Word.Range
The range to compare.
Returns
OfficeExtension.ClientResult<boolean>
true if the selection is contained within the specified range.
Remarks
isInStory(range)
Returns whether the selection is in the same story as the specified range.
isInStory(range: Word.Range): OfficeExtension.ClientResult<boolean>;
Parameters
- range
- Word.Range
The range to compare.
Returns
OfficeExtension.ClientResult<boolean>
true if the selection is in the same story as the specified range.
Remarks
load(options)
Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.
load(options?: Word.Interfaces.SelectionLoadOptions): Word.Selection;
Parameters
Provides options for which properties of the object to load.
Returns
load(propertyNames)
Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.
load(propertyNames?: string | string[]): Word.Selection;
Parameters
- propertyNames
-
string | string[]
A comma-delimited string or an array of strings that specify the properties to load.
Returns
load(propertyNamesAndPaths)
Queues up a command to load the specified properties of the object. You must call context.sync() before reading the properties.
load(propertyNamesAndPaths?: {
select?: string;
expand?: string;
}): Word.Selection;
Parameters
- propertyNamesAndPaths
-
{ select?: string; expand?: string; }
propertyNamesAndPaths.select is a comma-delimited string that specifies the properties to load, and propertyNamesAndPaths.expand is a comma-delimited string that specifies the navigation properties to load.
Returns
move(options)
Collapses the selection to its start or end position and then moves the collapsed object by the specified number of units.
move(options?: Word.SelectionMoveOptions): OfficeExtension.ClientResult<number>;
Parameters
- options
- Word.SelectionMoveOptions
Optional. Options for moving the selection.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveDown(options)
Moves the selection down.
moveDown(options?: Word.SelectionMoveUpDownOptions): OfficeExtension.ClientResult<number>;
Parameters
- options
- Word.SelectionMoveUpDownOptions
Optional. Options for moving down.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveEnd(options)
Moves the ending character position of the range or selection.
moveEnd(options?: Word.SelectionMoveStartEndOptions): OfficeExtension.ClientResult<number>;
Parameters
Optional. Options for moving end.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveEndUntil(characters, count)
Moves the end position of the selection until any of the specified characters are found in the document.
moveEndUntil(characters: string, count?: number): OfficeExtension.ClientResult<number>;
Parameters
- characters
-
string
Characters to search for. For example. If you specify "a", the selection moves the end position to before the first "a" character.
- count
-
number
Optional. Maximum number of characters to search.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveEndWhile(characters, count)
Moves the ending character position of the selection while any of the specified characters are found in the document.
moveEndWhile(characters: string, count?: number): OfficeExtension.ClientResult<number>;
Parameters
- characters
-
string
Characters to search for. For example. If you specify "abcd", the selection moves the end position when any letter from "abcd" is found.
- count
-
number
Optional. Maximum number of characters to search.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveLeft(options)
Moves the selection to the left.
moveLeft(options?: Word.SelectionMoveLeftRightOptions): OfficeExtension.ClientResult<number>;
Parameters
Optional. Options for moving left.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveRight(options)
Moves the selection to the right.
moveRight(options?: Word.SelectionMoveLeftRightOptions): OfficeExtension.ClientResult<number>;
Parameters
Optional. Options for moving right.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveStart(options)
Moves the start position of the selection.
moveStart(options?: Word.SelectionMoveStartEndOptions): OfficeExtension.ClientResult<number>;
Parameters
Optional. Options for the moveStart operation.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveStartUntil(characters, count)
Moves the start position of the selection until one of the specified characters is found in the document.
moveStartUntil(characters: string, count?: number): OfficeExtension.ClientResult<number>;
Parameters
- characters
-
string
Characters to search for. If you specify "a", the selection moves the start position to before the first "a" character.
- count
-
number
Optional. Maximum number of characters to search.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveStartWhile(characters, count)
Moves the start position of the selection while any of the specified characters are found in the document.
moveStartWhile(characters: string, count?: number): OfficeExtension.ClientResult<number>;
Parameters
- characters
-
string
Characters to search for. For example. If you specify "abcd", the selection moves the start position when any letter from "abcd" is found.
- count
-
number
Optional. Maximum number of characters to search.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveUntil(characters, count)
Moves the selection until one of the specified characters is found in the document.
moveUntil(characters: string, count?: number): OfficeExtension.ClientResult<number>;
Parameters
- characters
-
string
Characters to search for. For example. If you specify "a", the selection moves to the position before the first "a" character.
- count
-
number
Optional. Maximum number of characters to search.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveUp(options)
Moves the selection up.
moveUp(options?: Word.SelectionMoveUpDownOptions): OfficeExtension.ClientResult<number>;
Parameters
- options
- Word.SelectionMoveUpDownOptions
Optional. Options for moving up.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
moveWhile(characters, count)
Moves the selection while any of the specified characters are found in the document.
moveWhile(characters: string, count?: number): OfficeExtension.ClientResult<number>;
Parameters
- characters
-
string
Characters to search for. For example. If you specify "abcd", the selection moves to the position when any letter from "abcd" is found.
- count
-
number
Optional. Maximum number of characters to search.
Returns
OfficeExtension.ClientResult<number>
The number of characters by which the selection was moved.
Remarks
nextField()
Selects the next field.
nextField(): Word.Field;
Returns
The next field.
Remarks
nextSubdocument()
Moves the selection to the next subdocument.
nextSubdocument(): void;
Returns
void
Remarks
pasteAndFormat(type)
Pastes the content from clipboard and formats them as specified.
pasteAndFormat(type: Word.PasteFormatType): void;
Parameters
- type
- Word.PasteFormatType
The format paste type for table cells.
Returns
void
Remarks
pasteAndFormat(type)
Pastes the content from clipboard and formats them as specified.
pasteAndFormat(type: "PasteDefault" | "SingleCellText" | "SingleCellTable" | "ListContinueNumbering" | "ListRestartNumbering" | "TableAppendTable" | "TableInsertAsRows" | "TableOriginalFormatting" | "ChartPicture" | "Chart" | "ChartLinked" | "FormatOriginalFormatting" | "FormatSurroundingFormattingWithEmphasis" | "FormatPlainText" | "TableOverwriteCells" | "ListCombineWithExistingList" | "ListDontMerge" | "UseDestinationStylesRecovery"): void;
Parameters
- type
-
"PasteDefault" | "SingleCellText" | "SingleCellTable" | "ListContinueNumbering" | "ListRestartNumbering" | "TableAppendTable" | "TableInsertAsRows" | "TableOriginalFormatting" | "ChartPicture" | "Chart" | "ChartLinked" | "FormatOriginalFormatting" | "FormatSurroundingFormattingWithEmphasis" | "FormatPlainText" | "TableOverwriteCells" | "ListCombineWithExistingList" | "ListDontMerge" | "UseDestinationStylesRecovery"
The format paste type for table cells.
Returns
void
Remarks
pasteExcelTable(linkedToExcel, wordFormatting, rtf)
Pastes and formats a Microsoft Excel table.
pasteExcelTable(linkedToExcel: boolean, wordFormatting: boolean, rtf: boolean): void;
Parameters
- linkedToExcel
-
boolean
Whether the table is linked to Excel.
- wordFormatting
-
boolean
Whether to apply Word formatting.
- rtf
-
boolean
Whether to paste as Rich Text Format (RTF).
Returns
void
Remarks
pasteFormat()
Applies formatting copied with the copyFormat method to the selection.
pasteFormat(): void;
Returns
void
Remarks
pasteTableCellsAppendTable()
Merges pasted cells into an existing table by inserting the pasted rows between the selected rows.
pasteTableCellsAppendTable(): void;
Returns
void
Remarks
pasteTableCellsAsNestedTable()
Pastes a cell or group of cells as a nested table into the selection.
pasteTableCellsAsNestedTable(): void;
Returns
void
Remarks
previousField()
Selects and returns the previous field.
previousField(): Word.Field;
Returns
The previous field.
Remarks
previousSubdocument()
Moves the selection to the previous subdocument.
previousSubdocument(): void;
Returns
void
Remarks
replaceParagraph()
Replaces the selection with a new paragraph.
replaceParagraph(): void;
Returns
void
Remarks
select()
selectCell()
Selects the entire cell containing the current selection when the selection is in a table.
selectCell(): void;
Returns
void
Remarks
selectColumn()
Selects the column that contains the insertion point, or selects all columns that contain the selection when the selection is in a table.
selectColumn(): void;
Returns
void
Remarks
selectCurrentAlignment()
Extends the selection forward until text with a different paragraph alignment is encountered.
selectCurrentAlignment(): void;
Returns
void
Remarks
selectCurrentColor()
Extends the selection forward until text with a different color is encountered.
selectCurrentColor(): void;
Returns
void
Remarks
selectCurrentFont()
Extends the selection forward until text in a different font or font size is encountered.
selectCurrentFont(): void;
Returns
void
Remarks
selectCurrentIndent()
Extends the selection forward until text with different left or right paragraph indents is encountered.
selectCurrentIndent(): void;
Returns
void
Remarks
selectCurrentSpacing()
Extends the selection forward until a paragraph with different line spacing is encountered.
selectCurrentSpacing(): void;
Returns
void
Remarks
selectCurrentTabs()
Extends the selection forward until a paragraph with different tab stops is encountered.
selectCurrentTabs(): void;
Returns
void
Remarks
selectRow()
Selects the row that contains the insertion point, or selects all rows that contain the selection when the selection is in a table.
selectRow(): void;
Returns
void
Remarks
setRange(start, end)
Sets the starting and ending character positions for the selection. Character position values start at the beginning of the story, with the first value being 0. All characters are counted, including nonprinting characters. Hidden characters are counted even if they're not displayed.
setRange(start: number, end: number): void;
Parameters
- start
-
number
The starting character position of the current story.
- end
-
number
The ending character position of the current story.
Returns
void
Remarks
shrink()
Shrinks the selection to the next smaller unit of text. The unit progression for this method is as follows: entire document, section, paragraph, sentence, word, insertion point.
shrink(): void;
Returns
void
Remarks
shrinkDiscontiguousSelection()
Cancels the selection of all but the most recently selected text when the current selection contains multiple, unconnected selections.
shrinkDiscontiguousSelection(): void;
Returns
void
Remarks
splitTable()
Inserts an empty paragraph above the first row in the selection. If the selection isn't in the first row of the table, the table is split into two tables. If the selection isn't in a table, an error occurs.
splitTable(): void;
Returns
void
Remarks
toggleCharacterCode()
Switches the selection between a Unicode character and its corresponding hexadecimal value.
toggleCharacterCode(): void;
Returns
void
Remarks
toJSON()
Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that's passed to it.) Whereas the original Word.Selection object is an API object, the toJSON method returns a plain JavaScript object (typed as Word.Interfaces.SelectionData) that contains shallow copies of any loaded child properties from the original object.
toJSON(): Word.Interfaces.SelectionData;
Returns
track()
Track the object for automatic adjustment based on surrounding changes in the document. This call is a shorthand for context.trackedObjects.add(thisObject). If you're using this object across .sync calls and outside the sequential execution of a ".run" batch, and get an "InvalidObjectPath" error when setting a property or invoking a method on the object, you need to add the object to the tracked object collection when the object was first created. If this object is part of a collection, you should also track the parent collection.
track(): Word.Selection;
Returns
typeBackspace()
Deletes the character preceding the selection (if collapsed) or the insertion point.
typeBackspace(): void;
Returns
void
Remarks
untrack()
Release the memory associated with this object, if it has previously been tracked. This call is shorthand for context.trackedObjects.remove(thisObject). Having many tracked objects slows down the host application, so please remember to free any objects you add, once you're done using them. You'll need to call context.sync() before the memory release takes effect.
untrack(): Word.Selection;