Class SlidesApp

幻灯片应用

创建并打开可修改的Presentations

// Open a presentation by ID.
var preso = SlidesApp.openById('PRESENTATION_ID_GOES_HERE');

// Create and open a presentation.
preso = SlidesApp.create('Presentation Name');

属性

属性类型说明
AlignmentPositionAlignmentPosition对齐位置类型的枚举。
ArrowStyleArrowStyleLine 可拥有的不同箭头样式的枚举。
AutoTextTypeAutoTextType自动文字类型的枚举。
AutofitTypeAutofitType自动调整类型的枚举。
CellMergeStateCellMergeState表格单元格的不同合并状态的枚举。
ColorTypeColorType颜色类型的枚举。
ContentAlignmentContentAlignment用于指定内容对齐方式的值的枚举。
DashStyleDashStyle一个 Line 可以拥有的不同短划线样式的枚举。
FillTypeFillType填充类型的枚举。
LineCategoryLineCategoryLine 类别的枚举。
LineFillTypeLineFillTypeLineFill 类型的枚举。
LineTypeLineTypeLine 类型的枚举。
LinkTypeLinkType链接类型的枚举。
ListPresetListPreset列表预设类型的枚举。
PageBackgroundTypePageBackgroundType页面背景类型的枚举。
PageElementTypePageElementType页面元素类型的枚举。
PageTypePageType网页类型的枚举。
ParagraphAlignmentParagraphAlignment表示段落对齐类型的枚举。
PlaceholderTypePlaceholderType占位符类型的枚举。
PredefinedLayoutPredefinedLayout预定义布局的枚举。
SelectionTypeSelectionType所选项类型的枚举。
ShapeTypeShapeType形状类型的枚举。
SheetsChartEmbedTypeSheetsChartEmbedTypeGoogle 表格图表嵌入类型的枚举。
SlideLinkingModeSlideLinkingMode枚举幻灯片的关联方式。
SlidePositionSlidePosition枚举幻灯片位置的类型。
SpacingModeSpacingMode间距模式类型的枚举。
TextBaselineOffsetTextBaselineOffset文本基线偏移量类型的枚举。
TextDirectionTextDirection一种文本方向类型的枚举。
ThemeColorTypeThemeColorType主题颜色的枚举。
VideoSourceTypeVideoSourceType视频来源类型的枚举。

方法

方法返回类型简介
create(name)Presentation创建并打开新的 Presentation
getActivePresentation()Presentation返回脚本容器绑定到的当前活跃演示文稿;如果没有活跃演示文稿,则返回 null
getUi()Ui返回演示文稿的用户界面环境的实例,该环境允许脚本添加菜单、对话框和边栏等功能。
newAffineTransformBuilder()AffineTransformBuilder返回一个新的 AffineTransformBuilder 以构建 AffineTransform
openById(id)Presentation打开具有指定 ID 的 Presentation
openByUrl(url)Presentation使用给定网址打开 Presentation

详细文档

create(name)

创建并打开新的 Presentation

参数

名称类型说明
nameString为创建的演示文稿指定的名称。

返回

Presentation - 具有指定名称的演示文稿。

授权

使用此方法的脚本需要通过以下一个或多个范围进行授权:

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

getActivePresentation()

返回脚本容器绑定到的当前活跃演示文稿;如果没有活跃演示文稿,则返回 null。如需与脚本不受容器限制的演示文稿交互,请改用 openById(id)

// Get the current presentation to which this script is bound.
var presentation = SlidesApp.getActivePresentation();
如果演示文稿已经打开,则返回同一演示文稿实例。

返回

Presentation

授权

使用此方法的脚本需要通过以下一个或多个范围进行授权:

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

getUi()

返回演示文稿的用户界面环境的实例,该环境允许脚本添加菜单、对话框和边栏等功能。脚本只能与已打开演示文稿的当前实例的界面交互,且仅当该脚本绑定到演示文稿时才交互。如需了解详情,请参阅菜单以及对话框和边栏指南。

// Add a custom menu to the active presentation, including a separator and a sub-menu.
function onOpen(e) {
  SlidesApp.getUi()
      .createMenu('My Menu')
      .addItem('My menu item', 'myFunction')
      .addSeparator()
      .addSubMenu(SlidesApp.getUi().createMenu('My sub-menu')
          .addItem('One sub-menu item', 'mySecondFunction')
          .addItem('Another sub-menu item', 'myThirdFunction'))
      .addToUi();
}

返回

Ui


newAffineTransformBuilder()

返回一个新的 AffineTransformBuilder 以构建 AffineTransform。构建器已使用身份仿真转换预设。

返回

AffineTransformBuilder


openById(id)

打开具有指定 ID 的 Presentation

// Open a presentation by ID.
var presentation = SlidesApp.openById('docId');
如果演示文稿已经打开,则返回同一演示文稿实例。

参数

名称类型说明
idString

返回

Presentation - 具有指定 ID 的演示文稿

授权

使用此方法的脚本需要通过以下一个或多个范围进行授权:

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

openByUrl(url)

打开具有指定网址的 Presentation

// Open a presentation by URL.
var presentation = SlidesApp.openByUrl('https://docs.google.com/presentation/d/docId/edit');
如果演示文稿已经打开,则返回同一演示文稿实例。

参数

名称类型说明
urlString

返回

Presentation - 包含指定网址的演示文稿

授权

使用此方法的脚本需要通过以下一个或多个范围进行授权:

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