Class SlidesApp

簡報應用程式

建立並開啟可編輯的 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用於指定內容對齊方式的值列舉。
DashStyleDashStyle列舉 Line 可採用的不同虛線樣式。
FillTypeFillType填入類型列舉。
LineCategoryLineCategoryLine 的類別列舉。
LineFillTypeLineFillTypeLineFill 類型的列舉。
LineTypeLineTypeLine 類型的列舉。
LinkTypeLinkType連結類型列舉。
ListPresetListPreset列舉清單預設集類型。
PageBackgroundTypePageBackgroundType列舉網頁背景類型。
PageElementTypePageElementType網頁元素類型列舉。
PageTypePageType列舉頁面類型。
ParagraphAlignmentParagraphAlignment段落對齊方式的列舉。
PlaceholderTypePlaceholderType預留位置類型的列舉。
PredefinedLayoutPredefinedLayout預先定義的版面配置列舉。
SelectionTypeSelectionType選取項目類型的列舉。
ShapeTypeShapeType形狀類型的列舉。
SheetsChartEmbedTypeSheetsChartEmbedType試算表圖表嵌入類型的列舉。
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()

傳回簡報使用者介面環境的執行個體,讓指令碼新增選單、對話方塊和側欄等功能。指令碼只能與目前開啟簡報執行個體的 UI 互動,且指令碼必須繫結至簡報。詳情請參閱選單對話方塊與側欄指南。

// 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:新的 AffineTransformBuilder


openById(id)

開啟具有指定 ID 的 Presentation

// Open a presentation by ID.
const presentation = SlidesApp.openById('docId');
如果簡報已開啟,系統會傳回相同的簡報執行個體。

參數

名稱類型說明
idString要開啟的簡報 ID。

回攻員

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