演示文稿中的母版。
母版包含一组布局的所有常见页面元素和常见属性。它们有以下三个用途:
- 母版上的占位符形状包含使用该母版的页面上所有占位符形状的默认文本样式和形状属性。
- 母版页的属性定义了其布局继承的通用页面属性。
- 幻灯片母版上的任何其他形状都会显示在使用该母版的所有幻灯片上,无论其布局如何。
方法
详细文档
get
获取网页的背景。
返回
Page - 页面的背景。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
获取与网页关联的 Color。
返回
Color - 网页的配色方案。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
get
get
get
get
获取网页的唯一 ID。页面和页面元素使用的对象 ID 共用相同的命名空间。
返回
String
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
返回具有给定 ID 的页面上的 Page;如果不存在,则返回 null。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| id | String | 要检索的页面元素的 ID。 | 
返回
Page - 具有指定 ID 的页面元素。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
返回在页面上呈现的 Page 对象的列表。
返回
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
get
返回指定 Placeholder 或 null 的占位符 Page 对象(如果没有匹配的占位符,则返回 null)。
如果存在多个类型相同的占位符,则返回占位符索引最小的占位符。如果有多个具有相同索引的匹配占位符,则会返回网页的网页元素集合中的第一个占位符。
const slide = SlidesApp.getActivePresentation().getSlides()[0]; const placeholder = slide.getPlaceholder( SlidesApp.PlaceholderType.CENTERED_TITLE, );
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| placeholder | Placeholder | 
返回
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
返回指定 Placeholder 的占位符 Page 对象和占位符索引,如果不存在占位符,则返回 null。
如果有多个占位符具有相同的类型和索引,则会返回网页的网页元素集合中的第一个占位符。
const slide = SlidesApp.getActivePresentation().getSlides()[0]; const placeholder = slide.getPlaceholder( SlidesApp.PlaceholderType.CENTERED_TITLE, 0, );
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| placeholder | Placeholder | |
| placeholder | Integer | 
返回
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
返回页面中的占位符 Page 对象的列表。
const master = SlidesApp.getActivePresentation().getMasters()[0]; Logger.log( `Number of placeholders in the master: ${master.getPlaceholders().length}`, );
返回
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
get
返回页面上的 Sheets 对象列表。
返回
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
get
get
get
group(pageElements)
对所有指定的页面元素进行分组。
同一网页上至少应有两个未包含在其他组中的页面元素。某些页面元素(例如 Videos、Tables 和 placeholder Shapes)无法分组。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| page | Page | 要分组的元素。 | 
返回
Group - 新组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Group 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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.
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| group | Group | 要复制和插入的组。 | 
返回
Group - 插入的组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面左上角插入一张图片,图片的默认大小取自指定的图片 Blob。
插入图片会从 Blob 中提取一次,并存储一个副本以在演示文稿中显示。图片大小不得超过 50MB,不得超过 2500 万像素,且必须为 PNG、JPEG 或 GIF 格式。
const slide = SlidesApp.getActivePresentation().getSlides()[0]; // Get the Drive image file with the given ID. const image = DriveApp.getFileById('123abc'); slide.insertImage(image);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| blob | Blob | 图片数据。 | 
返回
Image - 插入的图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在指定图片 blob 中,将图片插入页面上提供的位置和大小。
系统会在插入时从提供的 Blob 中提取一次图片,并存储一个副本以在演示文稿中显示。图片大小不得超过 50MB,不得超过 2500 万像素,且必须为 PNG、JPEG 或 GIF 格式。
为了保持图片的宽高比,系统会根据所提供的大小缩放图片并将其居中。
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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| blob | Blob | 图片数据。 | 
| left | Number | 图片的水平位置(以像素为单位),从页面左上角测量。 | 
| top | Number | 图片的垂直位置(以像素为单位),从页面左上角开始测量。 | 
| width | Number | 图片的宽度(以点为单位)。 | 
| height | Number | 图片的高度(以点为单位)。 | 
返回
Image - 插入的图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Image 的副本。
插入的图片在此页面上的位置取决于源图片在其相应页面上的位置。
如果所提供的图片是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的图片。
如果所提供的图片是从其他演示文稿复制的占位符,则从源演示文稿继承的属性会复制到该图片上。如果复制的占位符图片为空,则目标演示文稿中不会插入任何内容。
// 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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| image | Image | 要复制和插入的图片。 | 
返回
Image - 插入的图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面左上角插入一张图片,图片来自提供的网址,采用默认大小。
插入图片会从网址中提取一次图片,并存储一个副本以在演示文稿中显示。图片大小不得超过 50MB,不得超过 2500 万像素,且必须为 PNG、JPEG 或 GIF 格式。
提供的网址必须可公开访问,且不得大于 2KB。网址本身会随图片一起保存,并通过 Image.getSourceUrl() 公开。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| image | String | 图片网址。 | 
返回
Image - 插入的图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入来自指定网址的图片,并将其放置在指定位置并设置为指定大小。
插入图片会从网址中提取一次图片,并存储一个副本以在演示文稿中显示。图片大小不得超过 50MB,不得超过 2500 万像素,且必须为 PNG、JPEG 或 GIF 格式。
提供的网址必须可公开访问,且不得大于 2KB。网址本身会随图片一起保存,并通过 Image.getSourceUrl() 公开。
为了保持图片的宽高比,系统会根据所提供的大小缩放图片并将其居中。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| image | String | 图片网址。 | 
| left | Number | 图片的水平位置(以像素为单位),从页面左上角测量。 | 
| top | Number | 图片的垂直位置(以像素为单位),从页面左上角开始测量。 | 
| width | Number | 图片的宽度(以点为单位)。 | 
| height | Number | 图片的高度(以点为单位)。 | 
返回
Image - 插入的图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Line 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| line | Line | 要复制并插入的行。 | 
返回
Line - 插入的行。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入一条连接两个 connection sites 的线条。两个关联网站必须在此页面上。
// 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], );
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| line | Line | 要插入的行所属的类别。 | 
| start | Connection | 线条起点的连接点。 | 
| end | Connection | 线条末端的连接点。 | 
返回
Line - 插入的行。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入一条线。
// 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, );
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| line | Line | 要插入的行所属的类别。 | 
| start | Number | 线条起点的水平位置,以从页面左上角算起的像素为单位。 | 
| start | Number | 线条起点的垂直位置,以从页面左上角开始的点数为单位。 | 
| end | Number | 线条端点的水平位置,以从页面左上角开始的点为单位。 | 
| end | Number | 线条终点的垂直位置,以从页面左上角算起的像素为单位。 | 
返回
Line - 插入的行。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Page 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| page | Page | 要复制和插入的页面元素。 | 
返回
Page - 插入的页面元素。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Shape 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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.
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| shape | Shape | 要复制和插入的形状。 | 
返回
Shape - 插入的形状。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入形状。
系统会在页面左上角以默认大小插入形状。
// 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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| shape | Shape | 要插入的形状的类型。 | 
返回
Shape - 插入的形状。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
insert
在页面上插入 Google 表格图表。
图表会以默认大小插入到页面左上角。
插入的图表会与 Google 表格中的源图表相关联,这样您就可以更新该图表。其他协作者可以看到指向源电子表格的链接。
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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| source | Embedded | 要插入页面中的电子表格中的图表。 | 
返回
Sheets - 页面中插入的图表。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入 Google 表格图表,并指定其位置和大小。
为了保持图表的宽高比,系统会根据所提供的大小缩放和居中显示图表。
插入的图表会与 Google 表格中的源图表相关联,这样您就可以更新该图表。其他协作者可以看到指向源电子表格的链接。
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, );
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| source | Embedded | 要插入页面中的电子表格中的图表。 | 
| left | Number | 图表的水平位置(以像素为单位),从页面左上角开始测量。 | 
| top | Number | 图表的垂直位置(以像素为单位),从页面左上角开始测量。 | 
| width | Number | 图表的宽度(以点为单位)。 | 
| height | Number | 图表的高度(以点为单位)。 | 
返回
Sheets - 页面中插入的图表。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Sheets 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| sheets | Sheets | 要复制和插入的 Google 表格图表。 | 
返回
Sheets - 插入的 Google 表格图表。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上将 Google 表格图表插入为 Image。
图表的图片会以默认大小插入到页面左上角。
插入的图表图片未与 Google 表格中的源图表相关联。
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.
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| source | Embedded | 要插入页面中的电子表格中的图表。 | 
返回
Image - 页面中插入的图表图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
将 Google 表格图表作为 Image 插入页面中,并指定其位置和大小。
为了保持图表图片的宽高比,系统会根据所提供的尺寸缩放图片并将其居中。
插入的图表图片未与 Google 表格中的源图表相关联。
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, );
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| source | Embedded | 要插入页面中的电子表格中的图表。 | 
| left | Number | 图表的水平位置(以像素为单位),从页面左上角开始测量。 | 
| top | Number | 图表的垂直位置(以像素为单位),从页面左上角开始测量。 | 
| width | Number | 图表的宽度(以点为单位)。 | 
| height | Number | 图表的高度(以点为单位)。 | 
返回
Image - 页面中插入的图表图片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
insert
在页面上插入一个表格,并指定其位置和大小。
行和列会均匀分布在所创建的表格中。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| num | Integer | 表中的行数。 | 
| num | Integer | 表中的列数。 | 
| left | Number | 表格的横向位置,从页面左上角测量。 | 
| top | Number | 表格的垂直位置,从页面左上角测量。 | 
| width | Number | 表格的宽度。 | 
| height | Number | 表格的最小高度。实际呈现的表格的高度取决于文本字体大小等因素。 | 
返回
Table - 插入的表格。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Table 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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.
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| table | Table | 要复制和插入的表。 | 
返回
Table - 插入的表格。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入一个包含所提供字符串的文本框 Shape。
文本框形状会以默认大小插入到页面左上角。
// 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.
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| text | String | 文本框形状应包含的字符串。 | 
返回
Shape - 插入的文本框形状。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入一个包含所提供字符串的文本框 Shape。
// 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.
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| text | String | 文本框形状应包含的字符串。 | 
| left | Number | 文本框形状的水平位置,从页面左上角测量。 | 
| top | Number | 文本框形状的垂直位置,从页面左上角测量。 | 
| width | Number | 文本框形状的宽度。 | 
| height | Number | 文本框形状的高度。 | 
返回
Shape - 插入的文本框形状。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
insert
在网页上插入视频,并指定其位置和大小。
目前仅支持 YouTube 视频。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| video | String | 要插入的视频的网址。 | 
| left | Number | 视频的横向位置(以像素为单位),从页面左上角测量。 | 
| top | Number | 视频的垂直位置(以像素为单位),从页面左上角测量。 | 
| width | Number | 视频的宽度(以像素点为单位)。 | 
| height | Number | 视频的高度(以点为单位)。 | 
返回
Video - 插入的视频。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Video 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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.
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| video | Video | 要复制和插入的视频。 | 
返回
Video - 插入的视频。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
insert
在页面上插入所提供 Word 的副本。
插入的元素在此页面上的位置取决于来源元素在其相应页面上的位置。
如果所提供的元素是从当前演示文稿中复制的占位符,则从母版或布局页继承的属性也会继承到插入的元素。
如果所提供的元素是从其他演示文稿复制的占位符,则从母版或布局页继承的属性会复制到来源演示文稿中的元素。
// 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);
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| word | Word | 要复制和插入的组。 | 
返回
Word - 插入的艺术字。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
remove()
移除页面。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
replace
将与查找文本匹配的所有文本替换为替换文本。搜索不区分大小写。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| find | String | 要查找的文本。 | 
| replace | String | 要替换匹配文本的文本。 | 
返回
Integer - 发生次数的更改
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
replace
将与查找文本匹配的所有文本替换为替换文本。
参数
| 名称 | 类型 | 说明 | 
|---|---|---|
| find | String | 要查找的文本。 | 
| replace | String | 要替换匹配文本的文本。 | 
| match | Boolean | 如果为 true,则搜索区分大小写;如果为false,则搜索不区分大小写。 | 
返回
Integer - 发生次数的更改
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations
select
将当前演示文稿中的 Page 选为 current page selection,并移除之前的所有选择。
脚本只能访问运行脚本的用户的选择,并且只有在脚本绑定到演示文稿的情况下才能访问。
// 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.
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
- 
https://www.googleapis.com/auth/presentations.currentonly
- 
https://www.googleapis.com/auth/presentations