Class Presentation

Presentation

A presentation.

Methods

MethodReturn typeBrief description
addEditor(emailAddress)PresentationAdds the given user to the list of editors for the Presentation.
addEditor(user)PresentationAdds the given user to the list of editors for the Presentation.
addEditors(emailAddresses)PresentationAdds the given array of users to the list of editors for the Presentation.
addViewer(emailAddress)PresentationAdds the given user to the list of viewers for the Presentation.
addViewer(user)PresentationAdds the given user to the list of viewers for the Presentation.
addViewers(emailAddresses)PresentationAdds the given array of users to the list of viewers for the Presentation.
appendSlide()SlideAppends a slide to the end of the presentation using the PredefinedLayout.BLANK predefined layout based on the current master.
appendSlide(layout)SlideAppends a slide to the end of the presentation using the specified layout based on the current master.
appendSlide(predefinedLayout)SlideAppends a slide to the end of the presentation using the specified predefined layout based on the current master.
getEditors()User[]Gets the list of editors for this Presentation.
getId()StringGets the presentation's unique identifier.
getLayouts()Layout[]Gets the layouts in the presentation.
getMasters()Master[]Gets the masters in the presentation.
getName()StringGets the name or title of the presentation.
getNotesMaster()NotesMasterGets the notes master of the presentation
getNotesPageHeight()NumberGets the page height of the notes master and notes pages in the presentation in points.
getNotesPageWidth()NumberGets the page width of the notes master and notes pages in the presentation in points.
getPageHeight()NumberGets the page height of the slides, layouts, and masters in the presentation in points.
getPageWidth()NumberGets the page width of the slides, layouts, and masters in the presentation in points.
getSelection()SelectionGets the user’s selection in the active presentation.
getSlides()Slide[]Gets the slides in the presentation.
getUrl()StringRetrieves the URL to access this presentation.
getViewers()User[]Gets the list of viewers and commenters for this Presentation.
insertSlide(insertionIndex)SlideInserts a slide at the specified index in the presentation using the PredefinedLayout.BLANK predefined layout based on the current master.
insertSlide(insertionIndex, layout)SlideInserts a slide at the specified index in the presentation using the specified layout based on the current master.
insertSlide(insertionIndex, predefinedLayout)SlideInserts a slide at the specified index in the presentation using the specified predefined layout based on the current master.
removeEditor(emailAddress)PresentationRemoves the given user from the list of editors for the Presentation.
removeEditor(user)PresentationRemoves the given user from the list of editors for the Presentation.
removeViewer(emailAddress)PresentationRemoves the given user from the list of viewers and commenters for the Presentation.
removeViewer(user)PresentationRemoves the given user from the list of viewers and commenters for the Presentation.
replaceAllText(findText, replaceText)IntegerReplaces all instances of text matching find text with replace text.
replaceAllText(findText, replaceText, matchCase)IntegerReplaces all instances of text matching find text with replace text.
saveAndClose()voidSaves the current Presentation.
setName(name)voidSets the name or title of the presentation.

Detailed documentation

addEditor(emailAddress)

Adds the given user to the list of editors for the Presentation. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.

Parameters

NameTypeDescription
emailAddressStringthe email address of the user to add

Return

Presentation — this Presentation, for chaining


addEditor(user)

Adds the given user to the list of editors for the Presentation. If the user was already on the list of viewers, this method promotes the user out of the list of viewers.

Parameters

NameTypeDescription
userUsera representation of the user to add

Return

Presentation — this Presentation, for chaining


addEditors(emailAddresses)

Adds the given array of users to the list of editors for the Presentation. If any of the users were already on the list of viewers, this method promotes them out of the list of viewers.

Parameters

NameTypeDescription
emailAddressesString[]an array of email addresses of the users to add

Return

Presentation — this Presentation, for chaining


addViewer(emailAddress)

Adds the given user to the list of viewers for the Presentation. If the user was already on the list of editors, this method has no effect.

Parameters

NameTypeDescription
emailAddressStringthe email address of the user to add

Return

Presentation — this Presentation, for chaining


addViewer(user)

Adds the given user to the list of viewers for the Presentation. If the user was already on the list of editors, this method has no effect.

Parameters

NameTypeDescription
userUsera representation of the user to add

Return

Presentation — this Presentation, for chaining


addViewers(emailAddresses)

Adds the given array of users to the list of viewers for the Presentation. If any of the users were already on the list of editors, this method has no effect for them.

Parameters

NameTypeDescription
emailAddressesString[]an array of email addresses of the users to add

Return

Presentation — this Presentation, for chaining


appendSlide()

Appends a slide to the end of the presentation using the PredefinedLayout.BLANK predefined layout based on the current master. The current master is one of the following:

  • The master of the current last slide.
  • The first master in the presentation, if there is no slide.

Return

Slide — the new slide


appendSlide(layout)

Appends a slide to the end of the presentation using the specified layout based on the current master. The current master is one of the following:

  • The master of the current last slide.
  • The first master in the presentation, if there is no slide.

Parameters

NameTypeDescription
layoutLayoutThe layout to use for the new slide; it should be present in the current master.

Return

Slide — the new slide


appendSlide(predefinedLayout)

Appends a slide to the end of the presentation using the specified predefined layout based on the current master. The current master is one of the following:

  • The master of the current last slide.
  • The first master in the presentation, if there is no slide.

Parameters

NameTypeDescription
predefinedLayoutPredefinedLayoutThe predefined layout to use for the new slide; it should be present in the current master.

Return

Slide — the new slide


getEditors()

Gets the list of editors for this Presentation. If the user who executes the script does not have edit access to the Presentation, this method throws an exception.

Return

User[] — an array of users with edit permission


getId()

Gets the presentation's unique identifier. The presentation ID is used with SlidesApp.openById() to open a specific presentation instance.

Return

String


getLayouts()

Gets the layouts in the presentation.

Return

Layout[]


getMasters()

Gets the masters in the presentation.

Return

Master[]


getName()

Gets the name or title of the presentation.

Return

String


getNotesMaster()

Gets the notes master of the presentation

Return

NotesMaster


getNotesPageHeight()

Gets the page height of the notes master and notes pages in the presentation in points. They all have the same page height.

Return

Number


getNotesPageWidth()

Gets the page width of the notes master and notes pages in the presentation in points. They all have the same page width.

Return

Number


getPageHeight()

Gets the page height of the slides, layouts, and masters in the presentation in points. They all have the same page height.

Return

Number


getPageWidth()

Gets the page width of the slides, layouts, and masters in the presentation in points. They all have the same page width.

Return

Number


getSelection()

Gets the user’s selection in the active presentation. A script can only access the selection of the user who is running the script, and only if the script is bound to the presentation.

Note that the selection returned is the current effective selection. As the script performs various changes to the presentation, the selection is transformed to take them into account. For example if two shapes A and B are selected, and then the script removes shape B, the returned selection object is implicitly updated such that only shape A is selected.

 // Gets the current active page that is selected in the active presentation.
 var selection = SlidesApp.getActivePresentation().getSelection();
 var currentPage = selection.getCurrentPage();
 

Return

Selection — a representation of the user's selection, or null if the script is not bound to the presentation or if there is no valid user selection


getSlides()

Gets the slides in the presentation.

Return

Slide[]


getUrl()

Retrieves the URL to access this presentation.

 var presentation = SlidesApp.getActivePresentation();

 // Send out the link to open the presentation.
 MailApp.sendEmail("", presentation.getName(), presentation.getUrl());
 

Return

String — the URL to access the current presentation


getViewers()

Gets the list of viewers and commenters for this Presentation. If the user who executes the script does not have edit access to the Presentation, this method throws an exception.

Return

User[] — an array of users with view or comment permission


insertSlide(insertionIndex)

Inserts a slide at the specified index in the presentation using the PredefinedLayout.BLANK predefined layout based on the current master. The current master is one of the following:

  • The master of the previous slide.
  • The master of the first slide, if the insertionIndex is zero.
  • The first master in the presentation, if there is no slide.

Parameters

NameTypeDescription
insertionIndexIntegerThe zero-based index indicating where to insert the slide.

Return

Slide — the new slide


insertSlide(insertionIndex, layout)

Inserts a slide at the specified index in the presentation using the specified layout based on the current master. The current master is one of the following:

  • The master of the previous slide.
  • The master of the first slide, if the insertionIndex is zero.
  • The first master in the presentation, if there is no slide.

Parameters

NameTypeDescription
insertionIndexIntegerThe zero-based index indicating where to insert the slide.
layoutLayoutThe layout to use for the new slide; it should be present in the current master.

Return

Slide — the new slide


insertSlide(insertionIndex, predefinedLayout)

Inserts a slide at the specified index in the presentation using the specified predefined layout based on the current master. The current master is one of the following:

  • The master of the previous slide.
  • The master of the first slide, if the insertionIndex is zero.
  • The first master in the presentation, if there is no slide.

Parameters

NameTypeDescription
insertionIndexIntegerThe zero-based index indicating where to insert the slide.
predefinedLayoutPredefinedLayoutThe predefined layout to use for the new slide; it should be present in the current master.

Return

Slide — the new slide


removeEditor(emailAddress)

Removes the given user from the list of editors for the Presentation. This method does not block users from accessing the Presentation if they belong to a class of users who have general access — for example, if the Presentation is shared with the user's entire domain.

Parameters

NameTypeDescription
emailAddressStringthe email address of the user to remove

Return

Presentation — this Presentation, for chaining


removeEditor(user)

Removes the given user from the list of editors for the Presentation. This method does not block users from accessing the Presentation if they belong to a class of users who have general access — for example, if the Presentation is shared with the user's entire domain.

Parameters

NameTypeDescription
userUsera representation of the user to remove

Return

Presentation — this Presentation, for chaining


removeViewer(emailAddress)

Removes the given user from the list of viewers and commenters for the Presentation. This method has no effect if the user is an editor, not a viewer or commenter. This method also does not block users from accessing the Presentation if they belong to a class of users who have general access — for example, if the Presentation is shared with the user's entire domain.

Parameters

NameTypeDescription
emailAddressStringthe email address of the user to remove

Return

Presentation — this Presentation for chaining


removeViewer(user)

Removes the given user from the list of viewers and commenters for the Presentation. This method has no effect if the user is an editor, not a viewer. This method also does not block users from accessing the Presentation if they belong to a class of users who have general access — for example, if the Presentation is shared with the user's entire domain.

Parameters

NameTypeDescription
userUsera representation of the user to remove

Return

Presentation — this Presentation for chaining


replaceAllText(findText, replaceText)

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

Parameters

NameTypeDescription
findTextStringThe text to find.
replaceTextStringThe text to replace the matched text.

Return

Integer — the number of occurrences changed


replaceAllText(findText, replaceText, matchCase)

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

Parameters

NameTypeDescription
findTextStringThe text to find.
replaceTextStringThe text to replace the matched text.
matchCaseBooleanIf true, the search is case sensitive; if false, the search is case insensitive.

Return

Integer — the number of occurrences changed


saveAndClose()

Saves the current Presentation. Causes pending updates to be flushed and applied.

The saveAndClose() method is automatically invoked at the end of script execution for each open Presentation, even if the script execution terminated with an error.

A closed Presentation cannot be edited. Use one of the open methods on SlidesApp to reopen a given presentation for editing.


setName(name)

Sets the name or title of the presentation.

Parameters

NameTypeDescription
nameString

Send feedback about...

Apps Script
Apps Script