SlideApp for Google Slides

Gists

By recent Google updated, Class SlideApp is added to Google Slides. SlideApp will be bring a lot of applications. Here, I would like to introduce 2 samples.

1. Sidebar

function showSidebar() {
  var html = HtmlService
    .createHtmlOutput('Hello, world! <input type="button" value="Close" onclick="google.script.host.close()" />')
    .setTitle('My custom sidebar')
    .setWidth(300);
  SlidesApp.getUi().showSidebar(html);
}

2. Copy slides in existing Slide to a new Slide

This sample script create a new Slide with slides you want to copy.

function slideCopy() {
  var srcSlides = [1, 3]; // Page number you want to copy. In this sample, the top number is 1.
  var srcId = SlidesApp.getActivePresentation().getId(); // or fileId of source Slide.

  var dstId = DriveApp.getFileById(srcId).makeCopy().getId();
  var dstSlides = SlidesApp.openById(dstId).getSlides();
  for (var i in srcSlides) {
    dstSlides[srcSlides[i] - 1] = null;
  }
  var removeSlides = dstSlides.filter(function(e){return e != null});
  for (var i in removeSlides) {
    removeSlides[i].remove();
  }
}

References :

 Share!