Class SlidesApp

Google 幻灯片应用

创建并打开可修改的 Presentations

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

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

属性

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

方法

方法返回类型简介
create(name)Presentation创建并打开新的 Presentation
getActivePresentation()Presentation|null返回脚本所绑定到的容器的当前活跃演示,如果没有活跃演示,则返回 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.
const presentation = SlidesApp.getActivePresentation();
如果演示文稿已打开,则返回同一演示文稿实例。

返回

Presentation|null

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

  • 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.
const presentation = SlidesApp.openById('docId');
如果演示文稿已打开,则返回同一演示文稿实例。

参数

名称类型说明
idString

返回

Presentation - 具有指定 ID 的演示

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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

openByUrl(url)

使用给定的网址打开 Presentation

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

参数

名称类型说明
urlString

返回

Presentation - 具有指定网址的演示文稿

授权

使用此方法的脚本需要获得以下一项或多项范围的授权:

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