Class Link

  • TheLink object represents a hypertext link in Google Slides.

  • You can determine the type of a link using thegetLinkType() method.

  • Methods likegetLinkedSlide(),getSlideId(),getSlideIndex(), andgetSlidePosition() are used to retrieve information about linked slides for non-URL link types.

  • ThegetUrl() method is used to retrieve the URL for external web page links.

  • Accessing link information may require specific authorization scopes.

Link

A hypertext link.

Methods

MethodReturn typeBrief description
getLinkType()LinkTypeReturns theLinkType.
getLinkedSlide()Slide|nullReturns the linkedSlide for non-URL links types, if it exists.
getSlideId()String|nullReturns the ID of the linkedSlide ornull if theLinkType is notLinkType.SLIDE_ID.
getSlideIndex()Integer|nullReturns the zero-based index of the linkedSlide ornull if theLinkType is notLinkType.SLIDE_INDEX.
getSlidePosition()SlidePosition|nullReturns theSlidePosition of the linkedSlide ornull if theLinkType is notLinkType.SLIDE_POSITION.
getUrl()String|nullReturns the URL to the external web page ornull if theLinkType is notLinkType.URL.

Detailed documentation

getLinkType()

Returns theLinkType.

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

Return

LinkType

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getLinkedSlide()

Returns the linkedSlide for non-URL links types, if it exists. Returnsnull ifthe slide doesn't exist in the presentation, or if theLinkType isLinkType.URL.

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 followingscopes:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getSlideId()

Returns the ID of the linkedSlide ornull if theLinkType is notLinkType.SLIDE_ID.

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 followingscopes:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getSlideIndex()

Returns the zero-based index of the linkedSlide ornull if theLinkType is notLinkType.SLIDE_INDEX.

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 followingscopes:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getSlidePosition()

Returns theSlidePosition of the linkedSlide ornull if theLinkType is notLinkType.SLIDE_POSITION.

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

SlidePosition|null

Authorization

Scripts that use this method require authorization with one or more of the followingscopes:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

getUrl()

Returns the URL to the external web page ornull if theLinkType is notLinkType.URL.

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 followingscopes:

  • https://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.