演示文稿。
方法
详细文档
addEditor(emailAddress)
将指定用户添加到 Presentation
的编辑者列表中。如果用户已在观看者列表中,则此方法会将用户从观看者列表中提升出来。
参数
名称 | 类型 | 说明 |
---|---|---|
emailAddress | String | 要添加的用户的电子邮件地址。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
addEditor(user)
将指定用户添加到 Presentation
的编辑者列表中。如果用户已在观看者列表中,则此方法会将用户从观看者列表中提升出来。
参数
名称 | 类型 | 说明 |
---|---|---|
user | User | 表示要添加的用户。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
addEditors(emailAddresses)
将给定的用户数组添加到 Presentation
的编辑者列表中。如果有任何用户已位于查看者列表中,则此方法会将这些用户从查看者列表中移出。
参数
名称 | 类型 | 说明 |
---|---|---|
emailAddresses | String[] | 要添加的用户的电子邮件地址数组。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
addViewer(emailAddress)
将指定用户添加到 Presentation
的查看者列表中。如果用户已在编辑者列表中,则此方法无效。
参数
名称 | 类型 | 说明 |
---|---|---|
emailAddress | String | 要添加的用户的电子邮件地址。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
addViewer(user)
将指定用户添加到 Presentation
的查看者列表中。如果用户已在编辑者列表中,则此方法无效。
参数
名称 | 类型 | 说明 |
---|---|---|
user | User | 表示要添加的用户。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
addViewers(emailAddresses)
将给定用户数组添加到 Presentation
的查看者列表中。如果有任何用户已在编辑者列表中,则此方法对他们没有影响。
参数
名称 | 类型 | 说明 |
---|---|---|
emailAddresses | String[] | 要添加的用户的电子邮件地址数组。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
appendSlide()
根据当前母版,使用 PredefinedLayout.BLANK
预定义布局将幻灯片附加到演示文稿的末尾。当前主实例可以是以下某一项:
- 当前最后一张幻灯片的母版。
- 演示文稿中的第一张母版(如果没有幻灯片)。
弃踢回攻
Slide
- 附加的新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
appendSlide(layout)
appendSlide(predefinedLayout)
根据当前母版,使用指定的预定义布局将幻灯片附加到演示文稿的末尾。当前主实例可以是以下某一项:
- 当前最后一张幻灯片的母版。
- 演示文稿中的第一张母版(如果没有幻灯片)。
参数
名称 | 类型 | 说明 |
---|---|---|
predefinedLayout | PredefinedLayout | 用于新幻灯片的预定义布局;它应显示在当前母版中。 |
弃踢回攻
Slide
- 附加的新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
appendSlide(slide)
将所提供的 Slide
的副本附加到演示文稿的末尾。
如果要复制的幻灯片来自其他演示文稿,那么父母版和布局页如果在此演示文稿中尚不存在,系统也会复制这两页。
// Copy a slide from another presentation and appends it. var otherPresentation = SlidesApp.openById('presentationId'); var currentPresentation = SlidesApp.getActivePresentation(); var slide = otherPresentation.getSlides()[0]; currentPresentation.appendSlide(slide);
参数
名称 | 类型 | 说明 |
---|---|---|
slide | Slide | 要复制和附加的幻灯片。 |
弃踢回攻
Slide
- 附加的新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
appendSlide(slide, linkingMode)
将源演示文稿中所提供的 Slide
的副本附加到当前演示文稿的末尾,并按照 SlideLinkingMode
指定的方式设置幻灯片链接。
如果要复制的幻灯片来自其他演示文稿,那么父母版和布局页如果当前演示文稿中还没有这两页,也会进行复制。
如果链接模式为 SlideLinkingMode.LINKED
,则在调用 Slide.refreshSlide()
时,可以更新附加的幻灯片,使其与提供的源幻灯片匹配。其他协作者可以看到源幻灯片的链接。SlideLinkingMode.LINKED
不能与当前演示文稿中的源幻灯片搭配使用。
// Copy a slide from another presentation, then append and link it. var sourcePresentation = SlidesApp.openById('presentationId'); var currentPresentation = SlidesApp.getActivePresentation(); var slide = sourcePresentation.getSlides()[0]; var appendedSlide = currentPresentation.appendSlide(slide, SlidesApp.SlideLinkingMode.LINKED);
参数
名称 | 类型 | 说明 |
---|---|---|
slide | Slide | 要复制、附加和链接的幻灯片。 |
linkingMode | SlideLinkingMode | 要使用的链接模式。 |
弃踢回攻
Slide
- 新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getEditors()
获取此 Presentation
的编辑者列表。
弃踢回攻
User[]
- 具有修改权限的用户数组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getId()
获取演示文稿的唯一标识符。演示文稿 ID 与 SlidesApp.openById()
一起使用,用于打开特定的演示文稿实例。
弃踢回攻
String
- 此演示文稿的 ID。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getLayouts()
getMasters()
getName()
获取演示文稿的名称或标题。
弃踢回攻
String
- 此演示文稿的标题。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getNotesMaster()
获取演示文稿的备注母版。
弃踢回攻
NotesMaster
- 演示文稿的备注母版。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getNotesPageHeight()
获取演示文稿中备注母版和备注页的页面高度(以点为单位)。它们的页面高度相同。
弃踢回攻
Number
- 备注页面的高度(以点为单位)。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getNotesPageWidth()
获取演示文稿中备注母版和备注页的页面宽度(以点为单位)。它们的页面宽度相同。
弃踢回攻
Number
- 记事页面宽度(以点为单位)。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getPageElementById(id)
返回具有指定 ID 的 PageElement
,如果不存在,则返回 null
。
参数
名称 | 类型 | 说明 |
---|---|---|
id | String | 要检索的页面元素的 ID。 |
弃踢回攻
PageElement
- 具有指定 ID 的页面元素。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getPageHeight()
获取演示文稿中幻灯片、布局和母版的页面高度(以点为单位)。它们的页面高度相同。
弃踢回攻
Number
- 页面高度(以点为单位)。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getPageWidth()
获取演示文稿中幻灯片、布局和母版的页面宽度(以点为单位)。它们的页面宽度相同。
弃踢回攻
Number
- 页面宽度(以点为单位)。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getSelection()
获取用户在活动展示中的选择。仅当脚本已绑定到演示文稿时,脚本才能访问运行该脚本的用户的所选内容。
请注意,返回的选择是当前的有效选择。当脚本对呈现方式进行各种更改时,系统会对选择内容进行转换,以将这些更改考虑在内。例如,如果选择了两个形状 A 和 B,然后脚本移除了形状 B,则系统会隐式更新返回的选择对象,从而仅选择形状 A。
// Gets the current active page that is selected in the active presentation. var selection = SlidesApp.getActivePresentation().getSelection(); var currentPage = selection.getCurrentPage();
弃踢回攻
Selection
- 用户选择的表示形式,如果脚本未绑定到演示文稿或没有有效的用户选择,则为 null
。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getSlideById(id)
getSlides()
getUrl()
检索此演示文稿的网址。
var presentation = SlidesApp.getActivePresentation(); // Send out the link to open the presentation. MailApp.sendEmail("<email-address>", presentation.getName(), presentation.getUrl());
弃踢回攻
String
- 用于访问当前演示文稿的网址。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
getViewers()
获取此 Presentation
的查看者和评论者列表。
弃踢回攻
User[]
- 具有查看或评论权限的用户数组。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
insertSlide(insertionIndex)
根据当前的母版,使用 PredefinedLayout.BLANK
预定义布局在演示文稿的指定索引处插入幻灯片。当前主实例为以下之一:
- 上一张幻灯片的母版。
- 第一张幻灯片的母版(如果 insertIndex 为零)。
- 演示文稿中的第一张母版(如果没有幻灯片)。
参数
名称 | 类型 | 说明 |
---|---|---|
insertionIndex | Integer | 从零开始的索引,指示幻灯片的插入位置。 |
弃踢回攻
Slide
- 插入的新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
insertSlide(insertionIndex, layout)
根据当前母版使用指定布局在演示文稿的指定索引处插入幻灯片。当前主实例可以是以下某一项:
- 上一张幻灯片的母版。
- 第一张幻灯片的母版(如果 insertIndex 为零)。
- 演示文稿中的第一张母版(如果没有幻灯片)。
参数
名称 | 类型 | 说明 |
---|---|---|
insertionIndex | Integer | 从零开始的索引,指示幻灯片的插入位置。 |
layout | Layout | 用于新幻灯片的布局;应显示在当前母版中。 |
弃踢回攻
Slide
- 插入的新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
insertSlide(insertionIndex, predefinedLayout)
根据当前母版使用指定的预定义布局,在演示文稿的指定索引处插入幻灯片。当前主实例可以是以下某一项:
- 上一张幻灯片的母版。
- 第一张幻灯片的母版(如果 insertIndex 为零)。
- 演示文稿中的第一张母版(如果没有幻灯片)。
参数
名称 | 类型 | 说明 |
---|---|---|
insertionIndex | Integer | 从零开始的索引,指示幻灯片的插入位置。 |
predefinedLayout | PredefinedLayout | 用于新幻灯片的预定义布局;它应显示在当前母版中。 |
弃踢回攻
Slide
- 插入的新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
insertSlide(insertionIndex, slide)
在演示文稿的指定索引处插入提供的 Slide
的副本。
如果要复制的幻灯片来自其他演示文稿,那么父母版和布局页如果在此演示文稿中尚不存在,系统也会复制这两页。
// Copy a slide from another presentation and inserts it. var otherPresentation = SlidesApp.openById('presentationId'); var currentPresentation = SlidesApp.getActivePresentation(); var slide = otherPresentation.getSlides()[0]; var insertionIndex = 1; currentPresentation.insertSlide(insertionIndex, slide);
参数
名称 | 类型 | 说明 |
---|---|---|
insertionIndex | Integer | 从零开始的索引,指示幻灯片的插入位置。 |
slide | Slide | 要复制和插入的幻灯片。 |
弃踢回攻
Slide
- 插入的新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
insertSlide(insertionIndex, slide, linkingMode)
将源演示文稿中提供的 Slide
副本插入当前演示文稿的指定索引中,并按照 SlideLinkingMode
指定的方式设置幻灯片链接。
如果要复制的幻灯片来自其他演示文稿,那么父母版和布局页如果当前演示文稿中还没有这两页,也会进行复制。
如果链接模式为 SlideLinkingMode.LINKED
,则在调用 Slide.refreshSlide()
时,可以更新插入的幻灯片以与提供的源幻灯片匹配。其他协作者可以看到源幻灯片的链接。SlideLinkingMode.LINKED
不能与当前演示文稿中的源幻灯片搭配使用。
// Copy a slide from another presentation, then insert and link it. var sourcePresentation = SlidesApp.openById('presentationId'); var currentPresentation = SlidesApp.getActivePresentation(); var slide = sourcePresentation.getSlides()[0]; var insertionIndex = 1; var insertedSlide = currentPresentation.insertSlide( insertionIndex, slide, SlidesApp.SlideLinkingMode.LINKED);
参数
名称 | 类型 | 说明 |
---|---|---|
insertionIndex | Integer | 从零开始的索引,指示幻灯片的插入位置。 |
slide | Slide | 要复制和插入的幻灯片。 |
linkingMode | SlideLinkingMode | 要使用的链接模式。 |
弃踢回攻
Slide
- 新幻灯片。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
removeEditor(emailAddress)
从 Presentation
的编辑者列表中移除指定用户。如果用户属于具有常规访问权限的用户类(例如,与用户的整个网域共享 Presentation
,或者 Presentation
位于用户可以访问的共享云端硬盘中),则此方法不会阻止用户访问 Presentation
。
对于云端硬盘文件,此操作会同时将用户从查看者列表中移除。
参数
名称 | 类型 | 说明 |
---|---|---|
emailAddress | String | 要移除的用户的电子邮件地址。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
removeEditor(user)
从 Presentation
的编辑者列表中移除指定用户。如果用户属于具有常规访问权限的用户类(例如,与用户的整个网域共享 Presentation
,或者 Presentation
位于用户可以访问的共享云端硬盘中),则此方法不会阻止用户访问 Presentation
。
对于云端硬盘文件,此操作会同时将用户从查看者列表中移除。
参数
名称 | 类型 | 说明 |
---|---|---|
user | User | 表示要移除的用户。 |
弃踢回攻
Presentation
- 此 Presentation
,用于链接。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
removeViewer(emailAddress)
从 Presentation
的查看者和评论者列表中移除指定用户。如果用户是编辑者,而不是查看者或评论者,则此方法不会产生任何影响。如果用户属于具有常规访问权限的一类用户(例如,与用户的整个网域共享 Presentation
,或者 Presentation
位于用户可以访问的共享云端硬盘中),则此方法也不会阻止用户访问 Presentation
。
对于云端硬盘文件,此操作会同时将用户从编辑者列表中移除。
参数
名称 | 类型 | 说明 |
---|---|---|
emailAddress | String | 要移除的用户的电子邮件地址。 |
弃踢回攻
Presentation
- 用于链接的 Presentation
。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
removeViewer(user)
从 Presentation
的查看者和评论者列表中移除指定用户。如果用户是编辑者(而不是查看者),则此方法不会产生任何影响。如果用户属于具有常规访问权限的用户类(例如,如果 Presentation
与用户的整个网域共享,或者 Presentation
位于用户可以访问的共享云端硬盘中),则此方法也不会阻止用户访问 Presentation
。
对于云端硬盘文件,此操作会同时将用户从编辑者列表中移除。
参数
名称 | 类型 | 说明 |
---|---|---|
user | User | 表示要移除的用户。 |
弃踢回攻
Presentation
- 用于链接的 Presentation
。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
replaceAllText(findText, replaceText)
使用替换文本替换与查找文本匹配的所有文本实例。搜索不区分大小写。
参数
名称 | 类型 | 说明 |
---|---|---|
findText | String | 要查找的文本。 |
replaceText | String | 要替换匹配文本的文本。 |
弃踢回攻
Integer
- 发生次数已更改
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
replaceAllText(findText, replaceText, matchCase)
使用替换文本替换与查找文本匹配的所有文本实例。
参数
名称 | 类型 | 说明 |
---|---|---|
findText | String | 要查找的文本。 |
replaceText | String | 要替换匹配文本的文本。 |
matchCase | Boolean | 如果为 true ,则搜索区分大小写;如果为 false ,则搜索不区分大小写。 |
弃踢回攻
Integer
- 发生次数已更改
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
saveAndClose()
保存当前的 Presentation
。导致系统刷新和应用待处理的更新。
系统会在脚本执行结束时针对每个打开的 Presentation
自动调用 saveAndClose()
方法,即使脚本执行因错误而终止也是如此。
无法修改已关闭的Presentation
。使用 SlidesApp
上的任一 open 方法重新打开给定演示文稿进行编辑。
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations
setName(name)
设置演示文稿的名称或标题。
参数
名称 | 类型 | 说明 |
---|---|---|
name | String | 要为此演示文稿设置的名称。 |
授权
使用此方法的脚本需要获得以下一个或多个范围的授权:
-
https://www.googleapis.com/auth/presentations.currentonly
-
https://www.googleapis.com/auth/presentations