TextRange

A segment of the text contents of a `https://developers.google.com/apps-script/reference/slides/shape` or a `https://developers.google.com/apps-script/reference/slides/table-cell`.

If you use methods that edit how the text fits within a shape, any autofit settings applied to
the shape are deactivated.

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/slides/text-range#appendParagraph(String)` | `https://developers.google.com/apps-script/reference/slides/paragraph` | Appends a paragraph at the end of the text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#appendRange(TextRange)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Appends a copy of the provided text range to the end of the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#appendRange(TextRange,Boolean)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Appends a copy of the provided text range to the end of the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#appendText(String)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Appends text at the end of the text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#asRenderedString()` | `String` | Returns the rendered text bounded by this range of the associated shape or table cell in a format appropriate to display to end users. |
| `https://developers.google.com/apps-script/reference/slides/text-range#asString()` | `String` | Returns the raw text bounded by this range of the associated shape or table cell. |
| `https://developers.google.com/apps-script/reference/slides/text-range#clear()` | `void` | Clears the text bounded by this range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#clear(Integer,Integer)` | `void` | Clears the text bounded by the start and end offsets in the range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#find(String)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Returns all the ranges matching the search pattern in the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#find(String,Integer)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Returns all the ranges matching the search pattern in the current text range starting from the start offset. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getAutoTexts()` | `https://developers.google.com/apps-script/reference/slides/auto-text` | Returns the auto texts within the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getEndIndex()` | `Integer` | Returns the exclusive, 0-based index for the last character in this range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getLength()` | `Integer` | Returns the number of characters in this range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getLinks()` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Returns a collection of text ranges that correspond to all `https://developers.google.com/apps-script/reference/slides/link`s within the current text range or overlapping the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getListParagraphs()` | `https://developers.google.com/apps-script/reference/slides/paragraph` | Returns the paragraphs in lists that overlap the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getListStyle()` | `https://developers.google.com/apps-script/reference/slides/list-style` | Returns the `https://developers.google.com/apps-script/reference/slides/list-style` of the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getParagraphStyle()` | `https://developers.google.com/apps-script/reference/slides/paragraph-style` | Returns the `https://developers.google.com/apps-script/reference/slides/paragraph-style` of the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getParagraphs()` | `https://developers.google.com/apps-script/reference/slides/paragraph` | Returns the paragraphs that overlap the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getRange(Integer,Integer)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Returns a new `https://developers.google.com/apps-script/reference/slides/text-range#` covering part of the range from which it is derived. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getRuns()` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Returns the text runs that overlap the current text range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getStartIndex()` | `Integer` | Returns the inclusive, 0-based index for the first character in this range. |
| `https://developers.google.com/apps-script/reference/slides/text-range#getTextStyle()` | `https://developers.google.com/apps-script/reference/slides/text-style|null` | Returns the text style of the range, or `null` if the range is empty. |
| `https://developers.google.com/apps-script/reference/slides/text-range#insertParagraph(Integer,String)` | `https://developers.google.com/apps-script/reference/slides/paragraph` | Inserts a paragraph at the start offset. |
| `https://developers.google.com/apps-script/reference/slides/text-range#insertRange(Integer,TextRange)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Inserts a copy of the provided text range at the start offset. |
| `https://developers.google.com/apps-script/reference/slides/text-range#insertRange(Integer,TextRange,Boolean)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Inserts a copy of the provided text range at the start offset. |
| `https://developers.google.com/apps-script/reference/slides/text-range#insertText(Integer,String)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Inserts text at the start offset. |
| `https://developers.google.com/apps-script/reference/slides/text-range#isEmpty()` | `Boolean` | Returns `true` if there are no characters in this range, and returns `false` otherwise. |
| `https://developers.google.com/apps-script/reference/slides/text-range#replaceAllText(String,String)` | `Integer` | Replaces all instances of text matching find text with replace text. |
| `https://developers.google.com/apps-script/reference/slides/text-range#replaceAllText(String,String,Boolean)` | `Integer` | Replaces all instances of text matching find text with replace text. |
| `https://developers.google.com/apps-script/reference/slides/text-range#select()` | `void` | Selects only the `https://developers.google.com/apps-script/reference/slides/text-range#` in the active presentation and removes any previous selection. |
| `https://developers.google.com/apps-script/reference/slides/text-range#setText(String)` | `https://developers.google.com/apps-script/reference/slides/text-range#` | Sets the text bounded by this range of the associated shape or table cell. |

## Detailed documentation

### `appendParagraph(text)`

Appends a paragraph at the end of the text range. The paragraph maintains the styling of the
end of the current text range.

The provided text string is appended as a paragraph by adding at least one surrounding
newline character to the string.

When the provided text string contains newline characters (thus consisting of multiple
paragraphs), the final paragraph added is returned.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `text` | `String` | The string to append as a paragraph. |

#### Return


`https://developers.google.com/apps-script/reference/slides/paragraph` --- The appended `https://developers.google.com/apps-script/reference/slides/paragraph`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `appendRange(textRange)`

Appends a copy of the provided text range to the end of the current text range.

The formatting of the inserted text matches that of the source text.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `textRange` | `https://developers.google.com/apps-script/reference/slides/text-range#` | The text range to append. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- The text range representing the appended text.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `appendRange(textRange, matchSourceFormatting)`

Appends a copy of the provided text range to the end of the current text range.

If set to match the formatting of the destination text, `https://developers.google.com/apps-script/reference/slides/auto-text` within the provided
text range are replaced with their rendered values. Furthermore, any non-text elements within
the provided text range are not appended.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `textRange` | `https://developers.google.com/apps-script/reference/slides/text-range#` | The text range to append. |
| `matchSourceFormatting` | `Boolean` | If `true`, match the formatting of the source text; if `false`, match the formatting of the destination text. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- The text range representing the appended text.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `appendText(text)`

Appends text at the end of the text range. The text maintains the styling of the end of the
existing text.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `text` | `String` | The string to append. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- The text range representing the appended text.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `asRenderedString()`

Returns the rendered text bounded by this range of the associated shape or table cell in a
format appropriate to display to end users.

AutoText elements, such as generated slide numbers, are replaced with their rendered values.
Any non-text elements in the range are omitted.

#### Return


`String` --- The rendered text in the range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `asString()`

Returns the raw text bounded by this range of the associated shape or table cell.

AutoText elements such as generated slide numbers and any non-text elements in the range are
replaced with the Unicode character U+E907.

#### Return


`String` --- The raw text in the range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `clear()`

Clears the text bounded by this range.

Since the entire text in a Shape or TableCell must end in a newline, the final newline in
the text is not removed.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `clear(startOffset, endOffset)`

Clears the text bounded by the start and end offsets in the range.

Since the text must end in a newline, the final newline in text is not removed even if it's
covered by the given offsets.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `startOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the inclusive start index of the range to clear. The start offset must be equal to or greater than 0 and less than or equal to `endOffset`. `startOffset` must also be less than the length of the current range. |
| `endOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the exclusive end index of the range to clear. The `endOffset` must be equal to or greater than `startOffset`. `endOffset` must also be less than or equal to the length of the current range. |

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `find(pattern)`

Returns all the ranges matching the search pattern in the current text range. The search is
case sensitive.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `pattern` | `String` | The regular expression pattern to search; any backslashes in the pattern should be escaped. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- A list of text ranges.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `find(pattern, startOffset)`

Returns all the ranges matching the search pattern in the current text range starting from the
start offset. The search is case sensitive.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `pattern` | `String` | The regular expression pattern to search; any backslashes in the pattern should be escaped. |
| `startOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the inclusive start index of the range to search. `startOffset` must also be less than the length of the current range. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- A list of text ranges.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getAutoTexts()`

Returns the auto texts within the current text range.

#### Return


`https://developers.google.com/apps-script/reference/slides/auto-text` --- A list of auto texts.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getEndIndex()`

Returns the exclusive, 0-based index for the last character in this range. If the start and end
indices are equal, the range is considered to be empty.

#### Return


`Integer` --- The end index of the range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getLength()`

Returns the number of characters in this range.

#### Return


`Integer` --- The number of characters in this range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getLinks()`

Returns a collection of text ranges that correspond to all `https://developers.google.com/apps-script/reference/slides/link`s within the current
text range or overlapping the current text range.

Each returned range is guaranteed to span one link when it is created. Text modifications
can cause it to no longer represent exactly one link.

Each `https://developers.google.com/apps-script/reference/slides/link` on the returned ranges can be accessed via `https://developers.google.com/apps-script/reference/slides/text-style#getLink()`.

```javascript
// Accesses the first link on a TextRange object.
const textRange = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0].getText();
const linkTextRange = textRange.getLinks()[0];
const textStyle = linkTextRange.getTextStyle();
Logger.log(textStyle.hasLink());   // logs 'true'
const link = textStyle.getLink();  // Link object
```

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- A list of text ranges.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getListParagraphs()`

Returns the paragraphs in lists that overlap the current text range.

#### Return


`https://developers.google.com/apps-script/reference/slides/paragraph` --- A list of paragraphs in lists.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getListStyle()`

Returns the `https://developers.google.com/apps-script/reference/slides/list-style` of the current text range.

#### Return


`https://developers.google.com/apps-script/reference/slides/list-style` --- The list style of the current text range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getParagraphStyle()`

Returns the `https://developers.google.com/apps-script/reference/slides/paragraph-style` of the current text range.

#### Return


`https://developers.google.com/apps-script/reference/slides/paragraph-style` --- The paragraph style of the current text range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getParagraphs()`

Returns the paragraphs that overlap the current text range.

#### Return


`https://developers.google.com/apps-script/reference/slides/paragraph` --- A list of paragraphs.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getRange(startOffset, endOffset)`

Returns a new `https://developers.google.com/apps-script/reference/slides/text-range#` covering part of the range from which it is derived.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `startOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the inclusive start index of the returned range. The start offset must be equal to or greater than 0 and less than or equal to `endOffset`. `startOffset` must also be less than the length of the current range. |
| `endOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the exclusive end index of the returned range. The `endOffset` must be equal to or greater than `startOffset`. `endOffset` must also be less than or equal to the length of the current range. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- A new text range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getRuns()`

Returns the text runs that overlap the current text range. A text run is a segment of text
where all the characters have the same text style.

Each returned range is only guaranteed to span one run when it is created. Text or style
modifications can cause it to no longer represent exactly one run.

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- A list of text ranges.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getStartIndex()`

Returns the inclusive, 0-based index for the first character in this range. If the start and
end indices are equal, the range is considered to be empty.

#### Return


`Integer` --- The start index of the range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `getTextStyle()`

Returns the text style of the range, or `null` if the range is empty.

#### Return


`https://developers.google.com/apps-script/reference/slides/text-style|null` --- The text style of the range.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `insertParagraph(startOffset, text)`

Inserts a paragraph at the start offset. The paragraph maintains the styling of the current
text range at the start offset.

The provided text string is inserted as a paragraph by adding at least one surrounding
newline character to the string.

When the provided text string contains newline characters (thus consisting of multiple
paragraphs), the final paragraph added is returned.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `startOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the inclusive start index of the text to insert. |
| `text` | `String` | The string to insert. |

#### Return


`https://developers.google.com/apps-script/reference/slides/paragraph` --- The inserted `https://developers.google.com/apps-script/reference/slides/paragraph`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `insertRange(startOffset, textRange)`

Inserts a copy of the provided text range at the start offset.

The formatting of the inserted text matches that of the source text.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `startOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the inclusive start index of the text to insert. |
| `textRange` | `https://developers.google.com/apps-script/reference/slides/text-range#` | The text range to insert. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- The text range representing the inserted text.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `insertRange(startOffset, textRange, matchSourceFormatting)`

Inserts a copy of the provided text range at the start offset.

If set to match the formatting of the destination text, `https://developers.google.com/apps-script/reference/slides/auto-text` within the provided
text range are replaced with their rendered values. Furthermore, any non-text elements within
the provided text range are not inserted.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `startOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the inclusive start index of the text to insert. |
| `textRange` | `https://developers.google.com/apps-script/reference/slides/text-range#` | The text range to insert. |
| `matchSourceFormatting` | `Boolean` | If `true`, match the formatting of the source text; if `false`, match the formatting of the destination text. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- The text range representing the inserted text.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `insertText(startOffset, text)`

Inserts text at the start offset. The text maintains the styling of the existing text at the
start offset.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `startOffset` | `Integer` | The number of characters past the start index of the current text range used to determine the inclusive start index of the text to insert. |
| `text` | `String` | The string to insert. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- The text range representing the inserted text.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `isEmpty()`

Returns `true` if there are no characters in this range, and returns `false`
otherwise.

#### Return


`Boolean` --- `true` if there are no characters in this range, and returns `false`
otherwise.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `replaceAllText(findText, replaceText)`

Replaces all instances of text matching find text with replace text. The search is case
insensitive.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `findText` | `String` | The text to find. |
| `replaceText` | `String` | The text to replace the matched text. |

#### Return


`Integer` --- The number of occurrences changed.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `replaceAllText(findText, replaceText, matchCase)`

Replaces all instances of text matching find text with replace text.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `findText` | `String` | The text to find. |
| `replaceText` | `String` | The text to replace the matched text. |
| `matchCase` | `Boolean` | If `true`, the search is case sensitive; if `false`, the search is case insensitive. |

#### Return


`Integer` --- The number of occurrences changed.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `select()`

Selects only the `https://developers.google.com/apps-script/reference/slides/text-range#` in the active presentation and removes any previous
selection.

A script can only access the selection of the user who is running the script, and only if
the script is [bound](https://developers.google.com/apps-script/scripts_containers) to the presentation.

The parent `https://developers.google.com/apps-script/reference/slides/page` of the corresponding `https://developers.google.com/apps-script/reference/slides/shape` or the `https://developers.google.com/apps-script/reference/slides/table-cell` is set
as the `https://developers.google.com/apps-script/reference/slides/selection#getCurrentPage()`. The `https://developers.google.com/apps-script/reference/slides/shape` or the `https://developers.google.com/apps-script/reference/slides/table-cell` is set as the `https://developers.google.com/apps-script/reference/slides/selection#getPageElementRange()`.

The `https://developers.google.com/apps-script/reference/slides/selection` can be of two types:

- 1. Range of text, use select on a non-empty TextRange to select the range of the characters.
- 2. Cursor position, use an empty TextRange to place the cursor at the desired index.

  ```javascript
  const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
  shape.getText().setText('Hello');
  // Range selection: Select the text range "He".
  shape.getText().getRange(0, 2).select();
  // Cursor selection: Place the cursor after "H" like "H|ello".
  shape.getText().getRange(1, 1).select();
  ```

  #### Authorization

  Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):
  - `https://www.googleapis.com/auth/presentations.currentonly`
  - `https://www.googleapis.com/auth/presentations`

*** ** * ** ***

### `setText(newText)`

Sets the text bounded by this range of the associated shape or table cell. The text maintains
the styling of the start of the existing text.

#### Parameters

| Name | Type | Description |
|---|---|---|
| `newText` | `String` | The string to set as the new text. |

#### Return


`https://developers.google.com/apps-script/reference/slides/text-range#` --- The text range representing the set text.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/presentations.currentonly`
- `https://www.googleapis.com/auth/presentations`