Created
February 3, 2021 18:04
-
-
Save theterg/dd57a24c9293487ac1df8897673e585e to your computer and use it in GitHub Desktop.
Autofilling Google Slides from Google Sheets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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