Stay organized with collections
Save and categorize content based on your preferences.
Range
A range of elements in a document. The user's selection is represented as a Range, among
other uses. Scripts can only access the selection of the user who is running the script, and only
if the script is bound to the document.
// Bold all selected text.constselection=DocumentApp.getActiveDocument().getSelection();if(selection){constelements=selection.getRangeElements();for(leti=0;i < elements.length;i++){constelement=elements[i];// Only modify elements that can be edited as text; skip images and other// non-text elements.if(element.getElement().editAsText){consttext=element.getElement().editAsText();// Bold the selected part of the element, or the full element if it's// completely selected.if(element.isPartial()){text.setBold(element.getStartOffset(),element.getEndOffsetInclusive(),true,);}else{text.setBold(true);}}}}
Gets all elements in this Range, including any partial Text elements (for example, in the case
of a selection that includes only part of a Text element).
Gets all elements that the user has selected in the open instance of the document, including
any partially selected Text
elements.
Detailed documentation
getRangeElements()
Gets all elements in this Range, including any partial Text elements (for example, in the case
of a selection that includes only part of a Text element). To determine whether a
Text element is only partially included in the range, see RangeElement.isPartial().
Return
RangeElement[] — an array of elements, in the order they appear in the document
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-12-02 UTC."],[[["A `Range` represents a range of elements in a Google Doc, often used to represent the user's selection."],["Scripts can only access the selection of the user who is running them within the bound document."],["The `getRangeElements()` method retrieves all elements within the range, including partially selected text elements."],["The `getSelectedElements()` method is deprecated and has been replaced by `getRangeElements()`."]]],[]]
Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.
Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.
🎥 Watch TMZ Live
TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.