Class Page

  • Various elements such as charts, tables, text boxes, videos, and Word Art can be inserted into a Google Slides page using specific methods with options for position, size, and content.

  • Elements can be inserted with default settings or with explicitly defined position and size parameters.

  • Existing elements can be copied and inserted, with their original position influencing the inserted element's position.

  • Theremove() method allows for the deletion of a page.

  • Text on a page can be replaced usingreplaceAllText, with an option for case sensitivity.

Page

A page in a presentation.

Methods

MethodReturn typeBrief description
asLayout()LayoutReturns the page as a layout.
asMaster()MasterReturns the page as a master.
asSlide()SlideReturns the page as a slide.
getBackground()PageBackgroundGets the page's background.
getColorScheme()ColorSchemeGets theColorScheme associated with the page.
getGroups()Group[]Returns the list ofGroup objects on the page.
getImages()Image[]Returns the list ofImage objects on the page.
getLines()Line[]Returns the list ofLine objects on the page.
getObjectId()StringGets the unique ID for the page.
getPageElementById(id)PageElement|nullReturns thePageElement on the page with the given ID, ornull if none exists.
getPageElements()PageElement[]Returns the list ofPageElement objects rendered on the page.
getPageType()PageTypeGets the type of the page.
getPlaceholder(placeholderType)PageElement|nullReturns the placeholderPageElement object for a specifiedPlaceholderType ornull if a matching placeholder is not present.
getPlaceholder(placeholderType, placeholderIndex)PageElement|nullReturns the placeholderPageElement object for a specifiedPlaceholderType anda placeholder index, ornull if the placeholder is not present.
getPlaceholders()PageElement[]Returns the list of placeholderPageElement objects in the page.
getShapes()Shape[]Returns the list ofShape objects on the page.
getSheetsCharts()SheetsChart[]Returns the list ofSheetsChart objects on the page.
getTables()Table[]Returns the list ofTable objects on the page.
getVideos()Video[]Returns the list ofVideo objects on the page.
getWordArts()WordArt[]Returns the list ofWordArt objects on the page.
group(pageElements)GroupGroups all the specified page elements.
insertGroup(group)GroupInserts a copy of the providedGroup on the page.
insertImage(blobSource)ImageInserts an image at the top left corner of the page with a default size from the specifiedimage blob.
insertImage(blobSource, left, top, width, height)ImageInserts an image on the page with the provided position and size from the specified image blob.
insertImage(image)ImageInserts a copy of the providedImage on the page.
insertImage(imageUrl)ImageInserts an image at the top left corner of the page with a default size from the provided URL.
insertImage(imageUrl, left, top, width, height)ImageInserts an image on the page with the provided position and size from the provided URL.
insertLine(line)LineInserts a copy of the providedLine on the page.
insertLine(lineCategory, startConnectionSite, endConnectionSite)LineInserts a line on the page connecting twoconnection sites.
insertLine(lineCategory, startLeft, startTop, endLeft, endTop)LineInserts a line on the page.
insertPageElement(pageElement)PageElementInserts a copy of the providedPageElement on the page.
insertShape(shape)ShapeInserts a copy of the providedShape on the page.
insertShape(shapeType)ShapeInserts a shape on the page.
insertShape(shapeType, left, top, width, height)ShapeInserts a shape on the page.
insertSheetsChart(sourceChart)SheetsChartInserts a Google Sheets chart on the page.
insertSheetsChart(sourceChart, left, top, width, height)SheetsChartInserts a Google Sheets chart on the page with the provided position and size.
insertSheetsChart(sheetsChart)SheetsChartInserts a copy of the providedSheetsChart on the page.
insertSheetsChartAsImage(sourceChart)ImageInserts a Google Sheets chart as anImage on the page.
insertSheetsChartAsImage(sourceChart, left, top, width, height)ImageInserts a Google Sheets chart as anImage on the page with the provided position andsize.
insertTable(numRows, numColumns)TableInserts a table on the page.
insertTable(numRows, numColumns, left, top, width, height)TableInserts a table on the page with the provided position and size.
insertTable(table)TableInserts a copy of the providedTable on the page.
insertTextBox(text)ShapeInserts a text boxShape containing the provided string on the page.
insertTextBox(text, left, top, width, height)ShapeInserts a text boxShape containing the provided string on the page.
insertVideo(videoUrl)VideoInserts a video at the top left corner of the page with a default size.
insertVideo(videoUrl, left, top, width, height)VideoInserts a video on the page with the provided position and size.
insertVideo(video)VideoInserts a copy of the providedVideo on the page.
insertWordArt(wordArt)WordArtInserts a copy of the providedWordArt on the page.
remove()voidRemoves the page.
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.
selectAsCurrentPage()voidSelects thePage in the active presentation as thecurrent page selection and removes any previous selection.

Detailed documentation

asLayout()

Returns the page as a layout.

Return

Layout — The page as a layout.

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

asMaster()

Returns the page as a master.

Return

Master — The page as a master.

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

asSlide()

Returns the page as a slide.

Return

Slide — The page as a slide.

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

getBackground()

Gets the page's background.

Return

PageBackground — The page's background.

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

getColorScheme()

Gets theColorScheme associated with the page.

Return

ColorScheme — The page's color scheme.

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

getGroups()

Returns the list ofGroup objects on the page.

Return

Group[]

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

getImages()

Returns the list ofImage objects on the page.

Return

Image[]

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

getLines()

Returns the list ofLine objects on the page.

Return

Line[]

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

getObjectId()

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

Return

String

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

getPageElementById(id)

Returns thePageElement on the page with the given ID, ornull if none exists.

Parameters

NameTypeDescription
idStringThe ID of the page element that is being retrieved.

Return

PageElement|null — The page element with the given ID.

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

getPageElements()

Returns the list ofPageElement objects rendered on the page.

Return

PageElement[]

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

getPageType()

Gets the type of the page.

Return

PageType — The page type.

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

getPlaceholder(placeholderType)

Returns the placeholderPageElement object for a specifiedPlaceholderType ornull if a matching placeholder is not present.

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

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

Parameters

NameTypeDescription
placeholderTypePlaceholderType

Return

PageElement|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

getPlaceholder(placeholderType, placeholderIndex)

Returns the placeholderPageElement object for a specifiedPlaceholderType anda placeholder index, ornull if the placeholder is not present.

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

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

Parameters

NameTypeDescription
placeholderTypePlaceholderType
placeholderIndexInteger

Return

PageElement|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

getPlaceholders()

Returns the list of placeholderPageElement objects in the page.

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

Return

PageElement[]

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

getShapes()

Returns the list ofShape objects on the page.

Return

Shape[]

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

getSheetsCharts()

Returns the list ofSheetsChart objects on the page.

Return

SheetsChart[]

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

getTables()

Returns the list ofTable objects on the page.

Return

Table[]

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

getVideos()

Returns the list ofVideo objects on the page.

Return

Video[]

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

getWordArts()

Returns the list ofWordArt objects on the page.

Return

WordArt[]

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

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 anothergroup. Some page elements, such asVideos,Tables andplaceholder Shapes cannot be grouped.

Parameters

NameTypeDescription
pageElementsPageElement[]The elements to group together.

Return

Group — The new group.

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

insertGroup(group)

Inserts a copy of the providedGroup on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

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

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

insertImage(blobSource)

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

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

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

Parameters

NameTypeDescription
blobSourceBlobSourceThe image data.

Return

Image — The inserted image.

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

insertImage(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 providedBlobSource once at insertion time and a copyis stored for display inside the presentation. Images must be less than 50MB in size, cannotexceed 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 respectto the provided size.

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

Parameters

NameTypeDescription
blobSourceBlobSourceThe image data.
leftNumberThe horizontal position of the image in points, measured from the upper left corner of the page.
topNumberThe vertical position of the image in points, measured from the upper left corner of the page.
widthNumberThe width of the image in points.
heightNumberThe 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 followingscopes:

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

insertImage(image)

Inserts a copy of the providedImage on the page.

The inserted images's position on this page is determined from the source image's positionon 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 sourcepresentation. If the copied placeholder image is empty, nothing is inserted in the destinationpresentation.

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

Parameters

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

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

insertImage(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 thepresentation. Images must be less than 50MB in size, cannot exceed 25 megapixels, and must bein either in PNG, JPEG, or GIF format.

The provided URL must be publicly accessible and no larger than 2kB. The URL itself is savedwith the image and exposed viaImage.getSourceUrl().

Parameters

NameTypeDescription
imageUrlStringThe image URL.

Return

Image — The inserted image.

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

insertImage(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 thepresentation. Images must be less than 50MB in size, cannot exceed 25 megapixels, and must bein either in PNG, JPEG, or GIF format.

The provided URL must be publicly accessible and no larger than 2kB. The URL itself is savedwith the image and exposed viaImage.getSourceUrl().

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

Parameters

NameTypeDescription
imageUrlStringThe image URL.
leftNumberThe horizontal position of the image in points, measured from the upper left corner of the page.
topNumberThe vertical position of the image in points, measured from the upper left corner of the page.
widthNumberThe width of the image in points.
heightNumberThe 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 followingscopes:

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

insertLine(line)

Inserts a copy of the providedLine on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

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

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

insertLine(lineCategory, startConnectionSite, endConnectionSite)

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

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

Parameters

NameTypeDescription
lineCategoryLineCategoryThe category of the line to insert.
startConnectionSiteConnectionSiteThe connection site where the start of the line is to be connected.
endConnectionSiteConnectionSiteThe 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 followingscopes:

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

insertLine(lineCategory, startLeft, startTop, endLeft, endTop)

Inserts a line on the page.

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

Parameters

NameTypeDescription
lineCategoryLineCategoryThe category of the line to insert.
startLeftNumberThe horizontal position of the start point of the line, measured in points from the upper left corner of the page.
startTopNumberThe vertical position of the start point of the line, measured in points from the upper left corner of the page.
endLeftNumberThe horizontal position of the end point of the line, measured in points from the upper left corner of the page.
endTopNumberThe 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 followingscopes:

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

insertPageElement(pageElement)

Inserts a copy of the providedPageElement on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

NameTypeDescription
pageElementPageElementThe page element to be copied and inserted.

Return

PageElement — The inserted page element.

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

insertShape(shape)

Inserts a copy of the providedShape on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

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

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

insertShape(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.constslide=SlidesApp.getActivePresentation().getSlides()[0];// Also available for Layout, Master, and Page.slide.insertShape(SlidesApp.ShapeType.RECTANGLE);

Parameters

NameTypeDescription
shapeTypeShapeTypeThe type of shape to insert.

Return

Shape — The inserted shape.

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

insertShape(shapeType, left, top, width, height)

Inserts a shape on the page.

Parameters

NameTypeDescription
shapeTypeShapeTypeThe type of shape to insert.
leftNumberThe horizontal position of the shape, measured from the upper left corner of the page.
topNumberThe vertical position of the shape, measured from the upper left corner of the page.
widthNumberThe width of the shape.
heightNumberThe height of the shape.

Return

Shape — The inserted shape.

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

insertSheetsChart(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 beupdated. Other collaborators can see the link to the source spreadsheet.

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

Parameters

NameTypeDescription
sourceChartEmbeddedChartThe chart in a spreadsheet to be inserted in the page.

Return

SheetsChart — The inserted chart in the page.

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

insertSheetsChart(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 respectto the provided size.

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

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

Parameters

NameTypeDescription
sourceChartEmbeddedChartThe chart in a spreadsheet to be inserted in the page.
leftNumberThe horizontal position of the chart in points, measured from the upper left corner of the page.
topNumberThe vertical position of the chart in points, measured from the upper left corner of the page.
widthNumberThe width of the chart in points.
heightNumberThe height of the chart in points.

Return

SheetsChart — The inserted chart in the page.

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

insertSheetsChart(sheetsChart)

Inserts a copy of the providedSheetsChart on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

NameTypeDescription
sheetsChartSheetsChartThe sheets chart to be copied and inserted.

Return

SheetsChart — The inserted sheets chart.

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

insertSheetsChartAsImage(sourceChart)

Inserts a Google Sheets chart as anImage 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.

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

Parameters

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

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

insertSheetsChartAsImage(sourceChart, left, top, width, height)

Inserts a Google Sheets chart as anImage on the page with the provided position andsize.

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

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

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

Parameters

NameTypeDescription
sourceChartEmbeddedChartThe chart in a spreadsheet to be inserted in the page.
leftNumberThe horizontal position of the chart in points, measured from the upper left corner of the page.
topNumberThe vertical position of the chart in points, measured from the upper left corner of the page.
widthNumberThe width of the chart in points.
heightNumberThe 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 followingscopes:

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

insertTable(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

NameTypeDescription
numRowsIntegerThe number of rows in the table.
numColumnsIntegerThe 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 followingscopes:

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

insertTable(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

NameTypeDescription
numRowsIntegerThe number of rows in the table.
numColumnsIntegerThe number of columns in the table.
leftNumberThe horizontal position of the table, measured from the upper left corner of the page.
topNumberThe vertical position of the table, measured from the upper left corner of the page.
widthNumberThe width of the table.
heightNumberThe 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 followingscopes:

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

insertTable(table)

Inserts a copy of the providedTable on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

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

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

insertTextBox(text)

Inserts a text boxShape 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.constslide=SlidesApp.getActivePresentation().getSlides()[0];slide.insertTextBox('Hello');// Also available for Layout, Master, and Page.

Parameters

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

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

insertTextBox(text, left, top, width, height)

Inserts a text boxShape 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.constslide=SlidesApp.getActivePresentation().getSlides()[0];slide.insertTextBox('Hello',0,0,10,10);// Also available for Layout, Master, and Page.

Parameters

NameTypeDescription
textStringThe string the text box shape should contain.
leftNumberThe horizontal position of the text box shape, measured from the upper left corner of the page.
topNumberThe vertical position of the text box shape, measured from the upper left corner of the page.
widthNumberThe width of the text box shape.
heightNumberThe 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 followingscopes:

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

insertVideo(videoUrl)

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

Only YouTube videos are currently supported.

Parameters

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

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

insertVideo(videoUrl, left, top, width, height)

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

Only YouTube videos are currently supported.

Parameters

NameTypeDescription
videoUrlStringThe URL of the video to insert.
leftNumberThe horizontal position of the video in points, measured from the upper left corner of the page.
topNumberThe vertical position of the video in points, measured from the upper left corner of the page.
widthNumberThe width of the video in points.
heightNumberThe 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 followingscopes:

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

insertVideo(video)

Inserts a copy of the providedVideo on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

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

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

insertWordArt(wordArt)

Inserts a copy of the providedWordArt on the page.

The inserted element's position on this page is determined from the source element'sposition 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 sourcepresentation.

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

Parameters

NameTypeDescription
wordArtWordArtThe group to be copied and inserted.

Return

WordArt — The inserted word art.

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

remove()

Removes the page.

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

replaceAllText(findText, replaceText)

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

Parameters

NameTypeDescription
findTextStringThe text to find.
replaceTextStringThe 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 followingscopes:

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

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.
matchCaseBooleanIftrue, the search is case sensitive; iffalse, 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 followingscopes:

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

selectAsCurrentPage()

Selects thePage in the active presentation as thecurrent page selection and removes any previous selection.

A script can only access the selection of the user who is running the script, and only ifthe script isbound to the presentation.

// Select the first slide as the current page selection and replace any previous// selection.constslide=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 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.