Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Created November 13, 2017 05:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tanaikech/0d8110aa9a6f7c1b8848e10a702628a1 to your computer and use it in GitHub Desktop.
Save tanaikech/0d8110aa9a6f7c1b8848e10a702628a1 to your computer and use it in GitHub Desktop.
SlideApp for Google Slides

SlideApp for Google Slides

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 :

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment