Skip to content

Instantly share code, notes, and snippets.

@theterg
Created February 3, 2021 18:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theterg/dd57a24c9293487ac1df8897673e585e to your computer and use it in GitHub Desktop.
Save theterg/dd57a24c9293487ac1df8897673e585e to your computer and use it in GitHub Desktop.
Autofilling Google Slides from Google Sheets
function myFunction() {
var sheeturl = "https://docs.google.com/spreadsheets/d/11_gwfesnphiI6uy4HmnCNpzL-pX1572SPKDiiiROnKs/edit";
var ss = SpreadsheetApp.openByUrl(sheeturl);
var deck = SlidesApp.getActivePresentation();
var sheet = ss.getSheetByName("test");
var values = sheet.getRange('A2:B18').getValues();
var slides = deck.getSlides();
var template = slides[0];
values.forEach(function(page) {
var uid = page[0];
var cdx = page[1];
console.log('Duplicating template: ', uid, cdx)
template.duplicate();
slides = deck.getSlides();
template = slides[0];
slide = slides[1];
var shapes = slide.getShapes();
shapes.forEach(function(shape) {
shape.getText().replaceAllText('${location}', uid);
shape.getText().replaceAllText('${cdx}', cdx);
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment