演示文稿中的幻灯片。
这些网页包含您向观众展示的内容。大多数幻灯片都基于母版和布局。您可以在创建幻灯片时指定要为每张幻灯片使用哪个布局。
方法
详细文档
duplicate()
get Background()
获取网页的背景。
返回
Page - 页面的背景。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Color Scheme()
获取与网页关联的 Color。
返回
Color - 网页的配色方案。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Groups()
get Images()
get Layout()
get Lines()
get Notes Page()
get Object Id()
获取网页的唯一 ID。网页和网页元素使用的对象 ID 共享同一命名空间。
返回
String
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Element By Id(id)
返回具有指定 ID 的页面上的 Page,如果不存在,则返回 null。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
id | String | 要检索的页面元素的 ID。 |
返回
Page - 具有指定 ID 的页面元素。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Elements()
返回页面上呈现的 Page 对象列表。
返回
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Page Type()
get Placeholder(placeholderType)
返回指定 Placeholder 的占位符 Page 对象,如果不存在匹配的占位符,则返回 null。
如果存在多个相同类型的占位符,则返回占位符索引最小的那个。如果存在多个具有相同索引的匹配占位符,则返回网页的网页元素集合中的第一个占位符。
const slide = SlidesApp.getActivePresentation().getSlides()[0]; const placeholder = slide.getPlaceholder( SlidesApp.PlaceholderType.CENTERED_TITLE, );
参数
| 名称 | 类型 | 说明 |
|---|---|---|
placeholder | Placeholder |
返回
Page
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Placeholder(placeholderType, placeholderIndex)
返回指定 Placeholder 和占位索引的占位 Page 对象,如果不存在占位,则返回 null。
如果存在多个具有相同类型和索引的占位符,则返回网页的网页元素集合中的第一个占位符。
const slide = SlidesApp.getActivePresentation().getSlides()[0]; const placeholder = slide.getPlaceholder( SlidesApp.PlaceholderType.CENTERED_TITLE, 0, );
参数
| 名称 | 类型 | 说明 |
|---|---|---|
placeholder | Placeholder | |
placeholder | Integer |
返回
Page
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Placeholders()
返回网页中占位符 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 Shapes()
get Sheets Charts()
返回页面上 Sheets 对象的列表。
返回
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Slide Linking Mode()
返回一个 Slide,用于指明幻灯片是否已链接到另一张幻灯片。
返回
Slide - 幻灯片关联模式。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Source Presentation Id()
返回源 Presentation ID;如果幻灯片未关联,则返回 null。
只有当幻灯片链接到其他演示文稿中的幻灯片时,它才具有源 Presentation ID。
返回
String - 源演示 ID 或 null。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Source Slide Object Id()
返回源幻灯片 ID;如果幻灯片未关联,则返回 null。
只有当幻灯片链接到其他演示文稿中的幻灯片时,它才具有源幻灯片 ID。
返回
String - 源幻灯片 ID 或 null。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
get Tables()
get Videos()
get Word Arts()
group(pageElements)
将所有指定的页面元素分组。
同一网页上应至少有两个尚未归入其他组的网页元素。某些网页元素(例如 Videos、Tables 和 placeholder Shapes)无法分组。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
page | Page | 要分组在一起的元素。 |
返回
Group - 新群组。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
insert Group(group)
在网页上插入所提供 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 Image(blobSource)
在页面左上角插入指定图片 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 Image(blobSource, left, top, width, height)
在页面上插入指定图片 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(image)
在网页上插入所提供 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 Image(imageUrl)
在页面左上角插入一张默认大小的图片,图片来自提供的网址。
插入图片时,系统会从相应网址获取图片一次,并存储一份副本以在演示中显示。图片大小不得超过 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 Image(imageUrl, left, top, width, height)
在网页上插入一张图片,该图片具有指定的位置和大小,并来自指定的网址。
插入图片时,系统会从相应网址获取图片一次,并存储一份副本以在演示中显示。图片大小不得超过 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(line)
在网页上插入所提供 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 Line(lineCategory, startConnectionSite, endConnectionSite)
在页面上插入一条连接两个 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 Line(lineCategory, startLeft, startTop, endLeft, endTop)
在网页上插入一条线。
// 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 Element(pageElement)
在网页上插入所提供 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(shape)
在网页上插入所提供 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 Shape(shapeType)
在页面上插入形状。
系统会以默认大小将形状插入到页面左上角。
// 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 Shape(shapeType, left, top, width, height)
insert Sheets Chart(sourceChart)
在网页上插入 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 Sheets Chart(sourceChart, left, top, width, height)
在页面上插入具有指定位置和大小的 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 Chart(sheetsChart)
在网页上插入所提供 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 - 插入的工作表图表。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
insert Sheets Chart As Image(sourceChart)
将 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 Sheets Chart As Image(sourceChart, left, top, width, height)
将 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 Table(numRows, numColumns)
insert Table(numRows, numColumns, left, top, width, height)
在页面上插入具有指定位置和大小的表格。
创建的表格中的行和列均匀分布。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
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(table)
在网页上插入所提供 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 Text Box(text)
在网页上插入一个包含所提供字符串的文本框 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 Text Box(text, left, top, width, height)
在网页上插入一个包含所提供字符串的文本框 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 Video(videoUrl)
insert Video(videoUrl, left, top, width, height)
在网页上插入具有指定位置和大小的视频。
目前仅支持 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(video)
在网页上插入所提供 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 Art(wordArt)
在网页上插入所提供 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
is Skipped()
返回相应幻灯片在演示模式下是否会被跳过。
返回
Boolean - 如果在演示模式下跳过幻灯片,则为 True。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
move(index)
将幻灯片移动到指定索引。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
index | Integer | 幻灯片应移至的索引,基于移动前的幻灯片排列顺序。该指数应介于 0 和演示文稿中的幻灯片数量之间(含首尾)。 |
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
refresh Slide()
刷新幻灯片,以反映对链接的源幻灯片所做的任何更改。如果此幻灯片未关联,则返回而不进行任何更改。
如果链接的源幻灯片的相应母版和布局页面尚不存在,refresh 方法会将它们复制到幻灯片的演示文稿中。如果这些数据源已存在,系统也会更新它们,以反映对来源所做的任何更改。
const currentPresentation = SlidesApp.getActivePresentation(); const sourcePresentation = SlidesApp.openById('sourcePresentationId'); const sourceSlide = sourcePresentation.getSlides()[0]; const linkedSlide = currentPresentation.append( sourceSlide, SlidesApp.SlideLinkingMode.LINKED, ); sourceSlide.insertText( 'hello world'); // Only the source slide has the text box. linkedSlide.refreshSlide(); // The linked slide now has the text box.
抛出
Error - 如果不再具有对源演示的读取权限。
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
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 All Text(findText, replaceText)
将与查找文本匹配的所有文本实例替换为替换文本。搜索不区分大小写。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
find | String | 要查找的文本。 |
replace | String | 用于替换匹配文本的文本。 |
返回
Integer - 更改后的出现次数
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
replace All Text(findText, replaceText, matchCase)
将与查找文本匹配的所有文本实例替换为替换文本。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
find | String | 要查找的文本。 |
replace | String | 用于替换匹配文本的文本。 |
match | Boolean | 如果值为 true,则搜索区分大小写;如果值为 false,则搜索不区分大小写。 |
返回
Integer - 更改后的出现次数
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
select As Current Page()
选择当前演示中的 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
set Skipped(isSkipped)
设置在演示模式下是否跳过相应幻灯片。
参数
| 名称 | 类型 | 说明 |
|---|---|---|
is | Boolean | True 以在演示模式下跳过相应幻灯片。 |
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations
unlink()
取消当前 Slide 与其来源幻灯片的关联。如果此幻灯片未关联,则返回而不进行任何更改。
const currentPresentation = SlidesApp.getActivePresentation(); const sourcePresentation = SlidesApp.openById('sourcePresentationId'); const sourceSlide = sourcePresentation.getSlides()[0]; const linkedSlide = currentPresentation.append( sourceSlide, SlidesApp.SlideLinkingMode.LINKED, ); linkedSlide.unlink(); linkedSlide.getSourcePresentationId(); // returns null linkedSlide.getSourceSlideObjectId(); // returns null linkedSlide .getSlideLinkingMode(); // returns SlidesApp.SlideLinkingMode.NOT_LINKED
授权
使用此方法的脚本需要获得以下一项或多项范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly -
https://www.googleapis.com/auth/presentations