Class Link
Stay organized with collections
Save and categorize content based on your preferences.
Page Summary
-
The
Linkobject represents a hypertext link in Google Slides. -
You can determine the type of a link using the
getLinkType()method. -
Methods like
getLinkedSlide(),getSlideId(),getSlideIndex(), andgetSlidePosition()are used to retrieve information about linked slides for non-URL link types. -
The
getUrl()method is used to retrieve the URL for external web page links. -
Accessing link information may require specific authorization scopes.
A hypertext link.
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Link | Returns the Link. |
get | Slide|null | Returns the linked Slide for non-URL links types, if it exists. |
get | String|null | Returns the ID of the linked Slide or null if the Link is not
Link. |
get | Integer|null | Returns the zero-based index of the linked Slide or null if the Link is not Link. |
get | Slide | Returns the Slide of the linked Slide or null if the Link is not Link. |
get | String|null | Returns the URL to the external web page or null if the Link is not Link. |
Detailed documentation
getLinkType()
Returns the Link.
constshape=SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0]; constlink=shape.getLink(); if(link!=null){ Logger.log(`Shape has a link of type: ${link.getLinkType()}`); }
Return
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
getLinkedSlide()
Returns the linked Slide for non-URL links types, if it exists. Returns null if
the slide doesn't exist in the presentation, or if the Link is Link.
constshape=SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0]; constlink=shape.getLink(); if(link!=null && link.getLinkType()!==SlidesApp.LinkType.URL){ Logger.log(`Shape has link to slide: ${link.getLinkedSlide()}`); }
Return
Slide|null
Authorization
Scripts that use this method require authorization with one or more of the following scopes:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
getSlideId()
Returns the ID of the linked Slide or null if the Link is not
Link.
Note that the slide with the returned ID might not exist.
constshape=SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0]; constlink=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://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
getSlideIndex()
Returns the zero-based index of the linked Slide or null if the Link is not Link.
Note that the slide at the returned index might not exist.
constshape=SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0]; constlink=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://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
getSlidePosition()
Returns the Slide of the linked Slide or null if the Link is not Link.
Note that the slide with the returned relative position might not exist.
constshape=SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0]; constlink=shape.getLink(); if(link!=null && link.getLinkType()===SlidesApp.LinkType.SLIDE_POSITION){ Logger.log( `Shape has link to slide with relative position: ${ link.getSlidePosition()}`, ); }
Return
Slide
Authorization
Scripts that use this method require authorization with one or more of the following 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 Link is not Link.
constshape=SlidesApp.getActivePresentation().getSlides()[0].getShapes()[0]; constlink=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://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations