Class Layout

Layout

A layout in a presentation.

Each layout serves as a template for slides that inherit from it, determining how content on those slides is arranged and styled.

Methods

Method Return type Brief description
Page Background Gets the page's background.
Color Scheme Gets the Color Scheme associated with the page.
Group[] Returns the list of Group objects on the page.
Image[] Returns the list of Image objects on the page.
String Gets the name of the layout.
Line[] Returns the list of Line objects on the page.
Master Gets the master that the layout is based on.
String Gets the unique ID for the page.
Page Element Returns the Page Element on the page with the given ID, or null if none exists.
Page Element[] Returns the list of Page Element objects rendered on the page.
Page Type Gets the type of the page.
Page Element Returns the placeholder Page Element object for a specified Placeholder Type or null if a matching placeholder is not present.
Page Element Returns the placeholder Page Element object for a specified Placeholder Type and a placeholder index, or null if the placeholder is not present.
Page Element[] Returns the list of placeholder Page Element objects in the page.
Shape[] Returns the list of Shape objects on the page.
Sheets Chart[] Returns the list of Sheets Chart objects on the page.
Table[] Returns the list of Table objects on the page.
Video[] Returns the list of Video objects on the page.
Word Art[] Returns the list of Word Art objects on the page.
Group Groups all the specified page elements.
Group Inserts a copy of the provided Group on the page.
Image Inserts an image at the top left corner of the page with a default size from the specified image blob.
Image Inserts an image on the page with the provided position and size from the specified image blob.
Image Inserts a copy of the provided Image on the page.
Image Inserts an image at the top left corner of the page with a default size from the provided URL.
Image Inserts an image on the page with the provided position and size from the provided URL.
Line Inserts a copy of the provided Line on the page.
Line Inserts a line on the page connecting two connection sites .
Line Inserts a line on the page.
Page Element Inserts a copy of the provided Page Element on the page.
Shape Inserts a copy of the provided Shape on the page.
Shape Inserts a shape on the page.
Shape Inserts a shape on the page.
Sheets Chart Inserts a Google Sheets chart on the page.
Sheets Chart Inserts a Google Sheets chart on the page with the provided position and size.
Sheets Chart Inserts a copy of the provided Sheets Chart on the page.
Image Inserts a Google Sheets chart as an Image on the page.
Image Inserts a Google Sheets chart as an Image on the page with the provided position and size.
Table Inserts a table on the page.
Table Inserts a table on the page with the provided position and size.
Table Inserts a copy of the provided Table on the page.
Shape Inserts a text box Shape containing the provided string on the page.
Shape Inserts a text box Shape containing the provided string on the page.
Video Inserts a video at the top left corner of the page with a default size.
Video Inserts a video on the page with the provided position and size.
Video Inserts a copy of the provided Video on the page.
Word Art Inserts a copy of the provided Word Art on the page.
void Removes the page.
Integer Replaces all instances of text matching find text with replace text.
Integer Replaces all instances of text matching find text with replace text.
void Selects the Page in the active presentation as the current page selection and removes any previous selection.

Detailed documentation

get Background()

Gets the page's background.

Return

Page Background — The page's background.

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

get Color Scheme()

Gets the Color Scheme associated with the page.

Return

Color Scheme — The page's color scheme.

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

get Groups()

Returns the list of Group objects on the page.

Return

Group[]

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

get Images()

Returns the list of Image objects on the page.

Return

Image[]

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

get Layout Name()

Gets the name of the layout.

Return

String

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

get Lines()

Returns the list of Line objects on the page.

Return

Line[]

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

get Master()

Gets the master that the layout is based on.

Return

Master

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

get Object Id()

Gets the unique ID for the page. Object IDs used by pages and page elements share the same namespace.

Return

String

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

get Page Element By Id(id)

Returns the Page Element on the page with the given ID, or null if none exists.

Parameters

Name Type Description
id
String The ID of the page element that is being retrieved.

Return

Page Element — The page element with the given ID.

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

get Page Elements()

Returns the list of Page Element objects rendered on the page.

Return

Page Element[]

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

get Page Type()

Gets the type of the page.

Return

Page Type — The page type.

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

get Placeholder(placeholderType)

Returns the placeholder Page Element object for a specified Placeholder Type or null if a matching placeholder is not present.

If there are multiple placeholders with the same type, it returns the one with minimal placeholder index. If there are multiple matching placeholders with the same index, it returns the first placeholder from the page's page elements collection.

 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 placeholder 
  
 = 
  
 slide 
 . 
 getPlaceholder 
 ( 
  
 SlidesApp 
 . 
 PlaceholderType 
 . 
 CENTERED_TITLE 
 , 
 ); 

Parameters

Name Type Description
placeholder Type
Placeholder Type

Return

Page Element

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

get Placeholder(placeholderType, placeholderIndex)

Returns the placeholder Page Element object for a specified Placeholder Type and a placeholder index, or null if the placeholder is not present.

If there are multiple placeholders with the same type and index, it returns the first placeholder from the page's page elements collection.

 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 placeholder 
  
 = 
  
 slide 
 . 
 getPlaceholder 
 ( 
  
 SlidesApp 
 . 
 PlaceholderType 
 . 
 CENTERED_TITLE 
 , 
  
 0 
 , 
 ); 

Parameters

Name Type Description
placeholder Type
Placeholder Type
placeholder Index
Integer

Return

Page Element

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

get Placeholders()

Returns the list of placeholder Page Element objects in the page.

 const 
  
 master 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getMasters 
 ()[ 
 0 
 ]; 
 Logger 
 . 
 log 
 ( 
  
 `Number of placeholders in the master: 
 ${ 
 master 
 . 
 getPlaceholders 
 (). 
 length 
 } 
 ` 
 , 
 ); 

Return

Page Element[]

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

get Shapes()

Returns the list of Shape objects on the page.

Return

Shape[]

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

get Sheets Charts()

Returns the list of Sheets Chart objects on the page.

Return

Sheets Chart[]

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

get Tables()

Returns the list of Table objects on the page.

Return

Table[]

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

get Videos()

Returns the list of Video objects on the page.

Return

Video[]

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

get Word Arts()

Returns the list of Word Art objects on the page.

Return

Word Art[]

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

group(pageElements)

Groups all the specified page elements.

There should be at least two page elements on the same page that are not already in another group. Some page elements, such as Videos , Tables and placeholder Shapes cannot be grouped.

Parameters

Name Type Description
page Elements
Page Element[] The elements to group together.

Return

Group — The new group.

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

insert Group(group)

Inserts a copy of the provided Group on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a group between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 group 
  
 = 
  
 otherPresentationSlide 
 . 
 getGroups 
 ()[ 
 0 
 ]; 
 currentPresentationSlide 
 . 
 insertGroup 
 ( 
  
 group 
 ); 
  
 // Also available for Layout, Master, and Page. 

Parameters

Name Type Description
group
Group The group to be copied and inserted.

Return

Group — The inserted group.

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

insert Image(blobSource)

Inserts an image at the top left corner of the page with a default size from the specified image blob.

Inserting the image fetches it from the Blob Source once and a copy is stored for display inside the presentation. Images must be less than 50MB in size, cannot exceed 25 megapixels, and must be in either in PNG, JPEG, or GIF format.

 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 // Get the Drive image file with the given ID. 
 const 
  
 image 
  
 = 
  
 DriveApp 
 . 
 getFileById 
 ( 
 '123abc' 
 ); 
 slide 
 . 
 insertImage 
 ( 
 image 
 ); 

Parameters

Name Type Description
blob Source
Blob Source The image data.

Return

Image — The inserted image.

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

insert Image(blobSource, left, top, width, height)

Inserts an image on the page with the provided position and size from the specified image blob.

The image is fetched from the provided Blob Source once at insertion time and a copy is stored for display inside the presentation. Images must be less than 50MB in size, cannot exceed 25 megapixels, and must be in either in PNG, JPEG, or GIF format.

In order to maintain the image's aspect ratio, the image is scaled and centered with respect to the provided size.

 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 // Get the Drive image file with the given ID. 
 const 
  
 image 
  
 = 
  
 DriveApp 
 . 
 getFileById 
 ( 
 '123abc' 
 ); 
 const 
  
 position 
  
 = 
  
 { 
  
 left 
 : 
  
 0 
 , 
  
 top 
 : 
  
 0 
 }; 
 const 
  
 size 
  
 = 
  
 { 
  
 width 
 : 
  
 300 
 , 
  
 height 
 : 
  
 100 
 }; 
 slide 
 . 
 insertImage 
 ( 
 image 
 , 
  
 position 
 . 
 left 
 , 
  
 position 
 . 
 top 
 , 
  
 size 
 . 
 width 
 , 
  
 size 
 . 
 height 
 ); 

Parameters

Name Type Description
blob Source
Blob Source The image data.
left
Number The horizontal position of the image in points, measured from the upper left corner of the page.
top
Number The vertical position of the image in points, measured from the upper left corner of the page.
width
Number The width of the image in points.
height
Number The height of the image in points.

Return

Image — The inserted image.

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

insert Image(image)

Inserts a copy of the provided Image on the page.

The inserted images's position on this page is determined from the source image's position on its respective page.

If the provided image is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted image.

If the provided image is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the image from the source presentation. If the copied placeholder image is empty, nothing is inserted in the destination presentation.

 // Copy an image between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 image 
  
 = 
  
 otherPresentationSlide 
 . 
 getImages 
 [ 
 0 
 ]; 
 currentPresentationSlide 
 . 
 insertImage 
 ( 
 image 
 ); 

Parameters

Name Type Description
image
Image The image to be copied and inserted.

Return

Image — The inserted image.

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

insert Image(imageUrl)

Inserts an image at the top left corner of the page with a default size from the provided URL.

Inserting the image fetches it from the URL once and a copy is stored for display inside the presentation. Images must be less than 50MB in size, cannot exceed 25 megapixels, and must be in either in PNG, JPEG, or GIF format.

The provided URL must be publicly accessible and no larger than 2kB. The URL itself is saved with the image and exposed via Image.getSourceUrl() .

Parameters

Name Type Description
image Url
String The image URL.

Return

Image — The inserted image.

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

insert Image(imageUrl, left, top, width, height)

Inserts an image on the page with the provided position and size from the provided URL.

Inserting the image fetches it from the URL once and a copy is stored for display inside the presentation. Images must be less than 50MB in size, cannot exceed 25 megapixels, and must be in either in PNG, JPEG, or GIF format.

The provided URL must be publicly accessible and no larger than 2kB. The URL itself is saved with the image and exposed via Image.getSourceUrl() .

In order to maintain the image's aspect ratio, the image is scaled and centered with respect to the provided size.

Parameters

Name Type Description
image Url
String The image URL.
left
Number The horizontal position of the image in points, measured from the upper left corner of the page.
top
Number The vertical position of the image in points, measured from the upper left corner of the page.
width
Number The width of the image in points.
height
Number The height of the image in points.

Return

Image — The inserted image.

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

insert Line(line)

Inserts a copy of the provided Line on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a line between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 line 
  
 = 
  
 otherPresentationSlide 
 . 
 getLines 
 [ 
 0 
 ]; 
 currentPresentationSlide 
 . 
 insertLine 
 ( 
 line 
 ); 

Parameters

Name Type Description
line
Line The line to be copied and inserted.

Return

Line — The inserted line.

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

insert Line(lineCategory, startConnectionSite, endConnectionSite)

Inserts a line on the page connecting two connection sites . The two connection sites must be on this page.

 // Insert a line in the first slide of the presentation connecting two shapes. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 shape1 
  
 = 
  
 slide 
 . 
 insertShape 
 ( 
 SlidesApp 
 . 
 ShapeType 
 . 
 RECTANGLE 
 ); 
 const 
  
 shape2 
  
 = 
  
 slide 
 . 
 insertShape 
 ( 
 SlidesApp 
 . 
 ShapeType 
 . 
 CLOUD 
 ); 
 slide 
 . 
 insertLine 
 ( 
  
 SlidesApp 
 . 
 LineCategory 
 . 
 BENT 
 , 
  
 shape1 
 . 
 getConnectionSites 
 ()[ 
 0 
 ], 
  
 shape2 
 . 
 getConnectionSites 
 ()[ 
 1 
 ], 
 ); 

Parameters

Name Type Description
line Category
Line Category The category of the line to insert.
start Connection Site
Connection Site The connection site where the start of the line is to be connected.
end Connection Site
Connection Site The connection site where the end of the line is to be connected.

Return

Line — The inserted line.

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

insert Line(lineCategory, startLeft, startTop, endLeft, endTop)

Inserts a line on the page.

 // Insert a line in the first slide of the presentation. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 startPoint 
  
 = 
  
 { 
  
 left 
 : 
  
 10 
 , 
  
 top 
 : 
  
 10 
 }; 
 const 
  
 endPoint 
  
 = 
  
 { 
  
 left 
 : 
  
 40 
 , 
  
 top 
 : 
  
 40 
 }; 
 slide 
 . 
 insertLine 
 ( 
  
 SlidesApp 
 . 
 LineCategory 
 . 
 STRAIGHT 
 , 
  
 startPoint 
 . 
 left 
 , 
  
 startPoint 
 . 
 top 
 , 
  
 endPoint 
 . 
 left 
 , 
  
 endPoint 
 . 
 top 
 , 
 ); 

Parameters

Name Type Description
line Category
Line Category The category of the line to insert.
start Left
Number The horizontal position of the start point of the line, measured in points from the upper left corner of the page.
start Top
Number The vertical position of the start point of the line, measured in points from the upper left corner of the page.
end Left
Number The horizontal position of the end point of the line, measured in points from the upper left corner of the page.
end Top
Number The vertical position of the end point of the line, measured in points from the upper left corner of the page.

Return

Line — The inserted line.

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

insert Page Element(pageElement)

Inserts a copy of the provided Page Element on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a page element between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 pageElement 
  
 = 
  
 otherPresentationSlide 
 . 
 getPageElements 
 ()[ 
 0 
 ]; 
 // Also available for Layout, Master, and Page. 
 currentPresentationSlide 
 . 
 insertPageElement 
 ( 
 pageElement 
 ); 

Parameters

Name Type Description
page Element
Page Element The page element to be copied and inserted.

Return

Page Element — The inserted page element.

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

insert Shape(shape)

Inserts a copy of the provided Shape on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a shape between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 shape 
  
 = 
  
 otherPresentationSlide 
 . 
 getShapes 
 [ 
 0 
 ]; 
 currentPresentationSlide 
 . 
 insertShape 
 ( 
  
 shape 
 ); 
  
 // Also available for Layout, Master, and Page. 

Parameters

Name Type Description
shape
Shape The shape to be copied and inserted.

Return

Shape — The inserted shape.

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

insert Shape(shapeType)

Inserts a shape on the page.

The shape is inserted with a default size at the top left corner of the page.

 // Insert a shape in the first slide of the presentation. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 // Also available for Layout, Master, and Page. 
 slide 
 . 
 insertShape 
 ( 
 SlidesApp 
 . 
 ShapeType 
 . 
 RECTANGLE 
 ); 

Parameters

Name Type Description
shape Type
Shape Type The type of shape to insert.

Return

Shape — The inserted shape.

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

insert Shape(shapeType, left, top, width, height)

Inserts a shape on the page.

Parameters

Name Type Description
shape Type
Shape Type The type of shape to insert.
left
Number The horizontal position of the shape, measured from the upper left corner of the page.
top
Number The vertical position of the shape, measured from the upper left corner of the page.
width
Number The width of the shape.
height
Number The height of the shape.

Return

Shape — The inserted shape.

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

insert Sheets Chart(sourceChart)

Inserts a Google Sheets chart on the page.

The chart is inserted with a default size at the top left corner of the page.

The inserted chart is linked with the source Google Sheets chart which allows it to be updated. Other collaborators can see the link to the source spreadsheet.

 const 
  
 sheet 
  
 = 
  
 SpreadsheetApp 
 . 
 openById 
 ( 
 'spreadsheetId' 
 ). 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 getCharts 
 ()[ 
 0 
 ]; 
 // Insert the spreadsheet chart in the first slide. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 slide 
 . 
 insertSheetsChart 
 ( 
 chart 
 ); 

Parameters

Name Type Description
source Chart
Embedded Chart The chart in a spreadsheet to be inserted in the page.

Return

Sheets Chart — The inserted chart in the page.

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

insert Sheets Chart(sourceChart, left, top, width, height)

Inserts a Google Sheets chart on the page with the provided position and size.

In order to maintain the chart's aspect ratio, the chart is scaled and centered with respect to the provided size.

The inserted chart is linked with the source Google Sheets chart which allows it to be updated. Other collaborators can see the link to the source spreadsheet.

 const 
  
 sheet 
  
 = 
  
 SpreadsheetApp 
 . 
 openById 
 ( 
 'spreadsheetId' 
 ). 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 getCharts 
 ()[ 
 0 
 ]; 
 // Insert the spreadsheet chart in the first slide. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 position 
  
 = 
  
 { 
  
 left 
 : 
  
 0 
 , 
  
 top 
 : 
  
 0 
 }; 
 const 
  
 size 
  
 = 
  
 { 
  
 width 
 : 
  
 200 
 , 
  
 height 
 : 
  
 200 
 }; 
 // Also available for Layout, Master, and Page. 
 slide 
 . 
 insertSheetsChart 
 ( 
  
 chart 
 , 
  
 position 
 . 
 left 
 , 
  
 position 
 . 
 top 
 , 
  
 size 
 . 
 width 
 , 
  
 size 
 . 
 height 
 , 
 ); 

Parameters

Name Type Description
source Chart
Embedded Chart The chart in a spreadsheet to be inserted in the page.
left
Number The horizontal position of the chart in points, measured from the upper left corner of the page.
top
Number The vertical position of the chart in points, measured from the upper left corner of the page.
width
Number The width of the chart in points.
height
Number The height of the chart in points.

Return

Sheets Chart — The inserted chart in the page.

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

insert Sheets Chart(sheetsChart)

Inserts a copy of the provided Sheets Chart on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a sheets chart between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 sheetsChart 
  
 = 
  
 otherPresentationSlide 
 . 
 getSheetsCharts 
 [ 
 0 
 ]; 
 // Also available for Layout, Master, and Page. 
 currentPresentationSlide 
 . 
 insertSheetsChart 
 ( 
 sheetsChart 
 ); 

Parameters

Name Type Description
sheets Chart
Sheets Chart The sheets chart to be copied and inserted.

Return

Sheets Chart — The inserted sheets chart.

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

insert Sheets Chart As Image(sourceChart)

Inserts a Google Sheets chart as an Image on the page.

The image of the chart is inserted with a default size at the top left corner of the page.

The inserted image of chart is not linked with the source Google Sheets chart.

 const 
  
 sheet 
  
 = 
  
 SpreadsheetApp 
 . 
 openById 
 ( 
 'spreadsheetId' 
 ). 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 getCharts 
 ()[ 
 0 
 ]; 
 // Insert the spreadsheet chart in the first slide. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 slide 
 . 
 insertSheetsChartAsImage 
 ( 
  
 chart 
 ); 
  
 // Also available for Layout, Master, and Page. 

Parameters

Name Type Description
source Chart
Embedded Chart The chart in a spreadsheet to be inserted in the page.

Return

Image — The inserted image of the chart in the page.

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

insert Sheets Chart As Image(sourceChart, left, top, width, height)

Inserts a Google Sheets chart as an Image on the page with the provided position and size.

In order to maintain the chart image's aspect ratio, the image is scaled and centered with respect to the provided size.

The inserted image of the chart is not linked with the source Google Sheets chart.

 const 
  
 sheet 
  
 = 
  
 SpreadsheetApp 
 . 
 openById 
 ( 
 'spreadsheetId' 
 ). 
 getSheets 
 ()[ 
 0 
 ]; 
 const 
  
 chart 
  
 = 
  
 sheet 
 . 
 getCharts 
 ()[ 
 0 
 ]; 
 // Insert the spreadsheet chart in the first slide. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 position 
  
 = 
  
 { 
  
 left 
 : 
  
 0 
 , 
  
 top 
 : 
  
 0 
 }; 
 const 
  
 size 
  
 = 
  
 { 
  
 width 
 : 
  
 200 
 , 
  
 height 
 : 
  
 200 
 }; 
 // Also available for Layout, Master, and Page. 
 slide 
 . 
 insertSheetsChartAsImage 
 ( 
  
 chart 
 , 
  
 position 
 . 
 left 
 , 
  
 position 
 . 
 right 
 , 
  
 size 
 . 
 width 
 , 
  
 size 
 . 
 height 
 , 
 ); 

Parameters

Name Type Description
source Chart
Embedded Chart The chart in a spreadsheet to be inserted in the page.
left
Number The horizontal position of the chart in points, measured from the upper left corner of the page.
top
Number The vertical position of the chart in points, measured from the upper left corner of the page.
width
Number The width of the chart in points.
height
Number The height of the chart in points.

Return

Image — The inserted image of the chart in the page.

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

insert Table(numRows, numColumns)

Inserts a table on the page.

The table is centered on the page with default size and evenly distributed rows and columns.

Parameters

Name Type Description
num Rows
Integer The number of rows in the table.
num Columns
Integer The number of columns in the table.

Return

Table — The inserted table.

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

insert Table(numRows, numColumns, left, top, width, height)

Inserts a table on the page with the provided position and size.

Rows and columns are evenly distributed in the created table.

Parameters

Name Type Description
num Rows
Integer The number of rows in the table.
num Columns
Integer The number of columns in the table.
left
Number The horizontal position of the table, measured from the upper left corner of the page.
top
Number The vertical position of the table, measured from the upper left corner of the page.
width
Number The width of the table.
height
Number The minimum height of the table. The actual height of the rendered table depends on factors such as text font size.

Return

Table — The inserted table.

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

insert Table(table)

Inserts a copy of the provided Table on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a table between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 table 
  
 = 
  
 otherPresentationSlide 
 . 
 getTables 
 [ 
 0 
 ]; 
 currentPresentationSlide 
 . 
 insertTable 
 ( 
  
 table 
 ); 
  
 // Also available for Layout, Master, and Page. 

Parameters

Name Type Description
table
Table The table to be copied and inserted.

Return

Table — The inserted table.

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

insert Text Box(text)

Inserts a text box Shape containing the provided string on the page.

The text box shape is inserted with a default size at the top left corner of the page.

 // Insert text box with "Hello" on the first slide of presentation. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 slide 
 . 
 insertTextBox 
 ( 
 'Hello' 
 ); 
  
 // Also available for Layout, Master, and Page. 

Parameters

Name Type Description
text
String The string the text box shape should contain.

Return

Shape — The inserted text box shape.

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

insert Text Box(text, left, top, width, height)

Inserts a text box Shape containing the provided string on the page.

 // Insert text box with "Hello" on the first slide of presentation. This text 
 // box is a square with a length of 10 points on each side. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 slide 
 . 
 insertTextBox 
 ( 
  
 'Hello' 
 , 
  
 0 
 , 
  
 0 
 , 
  
 10 
 , 
  
 10 
 ); 
  
 // Also available for Layout, Master, and Page. 

Parameters

Name Type Description
text
String The string the text box shape should contain.
left
Number The horizontal position of the text box shape, measured from the upper left corner of the page.
top
Number The vertical position of the text box shape, measured from the upper left corner of the page.
width
Number The width of the text box shape.
height
Number The height of the text box shape.

Return

Shape — The inserted text box shape.

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

insert Video(videoUrl)

Inserts a video at the top left corner of the page with a default size.

Only YouTube videos are currently supported.

Parameters

Name Type Description
video Url
String The URL of the video to insert.

Return

Video — The inserted video.

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

insert Video(videoUrl, left, top, width, height)

Inserts a video on the page with the provided position and size.

Only YouTube videos are currently supported.

Parameters

Name Type Description
video Url
String The URL of the video to insert.
left
Number The horizontal position of the video in points, measured from the upper left corner of the page.
top
Number The vertical position of the video in points, measured from the upper left corner of the page.
width
Number The width of the video in points.
height
Number The height of the video in points.

Return

Video — The inserted video.

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

insert Video(video)

Inserts a copy of the provided Video on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a video between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 video 
  
 = 
  
 otherPresentationSlide 
 . 
 getVideos 
 [ 
 0 
 ]; 
 currentPresentationSlide 
 . 
 insertVideo 
 ( 
  
 video 
 ); 
  
 // Also available for Layout, Master, and Page. 

Parameters

Name Type Description
video
Video The video to be copied and inserted.

Return

Video — The inserted video.

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

insert Word Art(wordArt)

Inserts a copy of the provided Word Art on the page.

The inserted element's position on this page is determined from the source element's position on its respective page.

If the provided element is a placeholder being copied from within the current presentation, properties that inherit from master or layout pages also inherit on the inserted element.

If the provided element is a placeholder being copied from a different presentation, properties that inherit from master or layout pages are copied onto the element from the source presentation.

 // Copy a word art between presentations. 
 const 
  
 otherPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 openById 
 ( 
 'presentationId' 
 ). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 currentPresentationSlide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 const 
  
 wordArt 
  
 = 
  
 otherPresentationSlide 
 . 
 getWordArts 
 [ 
 0 
 ]; 
 // Also available for Layout, Master, and Page. 
 currentPresentationSlide 
 . 
 insertWordArt 
 ( 
 wordArt 
 ); 

Parameters

Name Type Description
word Art
Word Art The group to be copied and inserted.

Return

Word Art — The inserted word art.

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

remove()

Removes the page.

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

replace All Text(findText, replaceText)

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

Parameters

Name Type Description
find Text
String The text to find.
replace Text
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://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

replace All Text(findText, replaceText, matchCase)

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

Parameters

Name Type Description
find Text
String The text to find.
replace Text
String The text to replace the matched text.
match Case
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://www.googleapis.com/auth/presentations.currentonly
  • https://www.googleapis.com/auth/presentations

select As Current Page()

Selects the Page in the active presentation as the current page selection 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 to the presentation.

 // Select the first slide as the current page selection and replace any previous 
 // selection. 
 const 
  
 slide 
  
 = 
  
 SlidesApp 
 . 
 getActivePresentation 
 (). 
 getSlides 
 ()[ 
 0 
 ]; 
 slide 
 . 
 selectAsCurrentPage 
 (); 
  
 // Also available for Layout, Master, and Page. 

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
Create a Mobile Website
View Site in Mobile | Classic
Share by: