Link

A hypertext link.

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/slides/link#getLinkType()` | `https://developers.google.com/apps-script/reference/slides/link-type` | Returns the `https://developers.google.com/apps-script/reference/slides/link-type`. |
| `https://developers.google.com/apps-script/reference/slides/link#getLinkedSlide()` | `https://developers.google.com/apps-script/reference/slides/slide|null` | Returns the linked `https://developers.google.com/apps-script/reference/slides/slide` for non-URL links types, if it exists. |
| `https://developers.google.com/apps-script/reference/slides/link#getSlideId()` | `String|null` | Returns the ID of the linked `https://developers.google.com/apps-script/reference/slides/slide` or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not `https://developers.google.com/apps-script/reference/slides/link-type#SLIDE_ID`. |
| `https://developers.google.com/apps-script/reference/slides/link#getSlideIndex()` | `Integer|null` | Returns the zero-based index of the linked `https://developers.google.com/apps-script/reference/slides/slide` or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not `https://developers.google.com/apps-script/reference/slides/link-type#SLIDE_INDEX`. |
| `https://developers.google.com/apps-script/reference/slides/link#getSlidePosition()` | `https://developers.google.com/apps-script/reference/slides/slide-position|null` | Returns the `https://developers.google.com/apps-script/reference/slides/slide-position` of the linked `https://developers.google.com/apps-script/reference/slides/slide` or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not `https://developers.google.com/apps-script/reference/slides/link-type#SLIDE_POSITION`. |
| `https://developers.google.com/apps-script/reference/slides/link#getUrl()` | `String|null` | Returns the URL to the external web page or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not `https://developers.google.com/apps-script/reference/slides/link-type#URL`. |

## Detailed documentation

### `getLinkType()`

Returns the `https://developers.google.com/apps-script/reference/slides/link-type`.

```javascript
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null) {
  Logger.log(`Shape has a link of type: ${link.getLinkType()}`);
}
```

#### Return


`https://developers.google.com/apps-script/reference/slides/link-type`

#### 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`

*** ** * ** ***

### `getLinkedSlide()`

Returns the linked `https://developers.google.com/apps-script/reference/slides/slide` for non-URL links types, if it exists. Returns `null` if
the slide doesn't exist in the presentation, or if the `https://developers.google.com/apps-script/reference/slides/link-type` is `https://developers.google.com/apps-script/reference/slides/link-type#URL`.

```javascript
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() !== SlidesApp.LinkType.URL) {
  Logger.log(`Shape has link to slide: ${link.getLinkedSlide()}`);
}
```

#### Return


`https://developers.google.com/apps-script/reference/slides/slide|null`

#### 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`

*** ** * ** ***

### `getSlideId()`

Returns the ID of the linked `https://developers.google.com/apps-script/reference/slides/slide` or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not
`https://developers.google.com/apps-script/reference/slides/link-type#SLIDE_ID`.

Note that the slide with the returned ID might not exist.

```javascript
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_ID) {
  Logger.log(`Shape has link to slide with ID: ${link.getSlideId()}`);
}
```

#### Return


`String|null`

#### 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`

*** ** * ** ***

### `getSlideIndex()`

Returns the zero-based index of the linked `https://developers.google.com/apps-script/reference/slides/slide` or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not `https://developers.google.com/apps-script/reference/slides/link-type#SLIDE_INDEX`.

Note that the slide at the returned index might not exist.

```javascript
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_INDEX) {
  Logger.log(`Shape has link to slide with index: ${link.getSlideIndex()}`);
}
```

#### Return


`Integer|null`

#### 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`

*** ** * ** ***

### `getSlidePosition()`

Returns the `https://developers.google.com/apps-script/reference/slides/slide-position` of the linked `https://developers.google.com/apps-script/reference/slides/slide` or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not `https://developers.google.com/apps-script/reference/slides/link-type#SLIDE_POSITION`.

Note that the slide with the returned relative position might not exist.

```javascript
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.SLIDE_POSITION) {
  Logger.log(
      `Shape has link to slide with relative position: ${
          link.getSlidePosition()}`,
  );
}
```

#### Return


`https://developers.google.com/apps-script/reference/slides/slide-position|null`

#### 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`

*** ** * ** ***

### `getUrl()`

Returns the URL to the external web page or `null` if the `https://developers.google.com/apps-script/reference/slides/link-type` is not `https://developers.google.com/apps-script/reference/slides/link-type#URL`.

```javascript
const shape = SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0];
const link = shape.getLink();
if (link != null && link.getLinkType() === SlidesApp.LinkType.URL) {
  Logger.log(`Shape has link to URL: ${link.getUrl()}`);
}
```

#### Return


`String|null`

#### 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`