Hey good people,
Before I get to my ask, a bit of a background on what i’m looking to achieve:
I have a Google Sheets file in which I maintain a list of entries (250-300)
Each entry is a song name
Each song name is referenced (by Document ID) to its own Google Slides file containing its lyrics (often spread across multiple individual slides)
Each song entry has a checkbox that is meant to select/deselect that song
What I’m trying to achieve is:
Create a script that runs through this spreadsheet, picks up only the slides referenced by the selected name entries
Consolidates all of the individual song lyrics from the slides, into a single setlist presentation.
Bottomline: A karaoke listing of the lyrics of all the selected songs.
The Google Apps Script code (that Gemini largely helped come up with!):
function consolidateSlides() {
// Get selected checkboxes (assuming checkboxes are in column A)
var sheet = SpreadsheetApp.getActiveSheet();
var selections = sheet.getRange("A:A").getValues(); // Adjust range if your checkbox column is different
// Create a new presentation (optional)
var newPresentation = SlidesApp.newPresentation();
// Initialize variables
var presentation = null;
var slides = [];
// Loop through selected checkboxes
for (var i = 0; i < selections.length; i++) {
if (selections[i][0]) { // Check if checkbox is selected (TRUE)
// Get the document ID from column C (adjust index if needed)
var documentId = sheet.getRange(i + 1, 3).getValue(); // Assuming IDs are in column C
// Open the Slide Deck by ID
if (documentId) {
presentation = SlidesApp.openById(documentId);
} else {
// Handle case where document ID is empty (optional: log error message)
continue;
}
// Extract slides and add them to the slides array
slides = slides.concat(presentation.getSlides());
}
}
// Add all collected slides to the new presentation
for (var i = 0; i < slides.length; i++) {
newPresentation.appendSlide(slides[i]);
}
}
The error:
Try as I might (and I’ve apwnr hours of debugging sessions on this with Google Gemini), I consistently get the following error:
TypeError: SlidesApp.newPresentation is not a function
I believe this implies the Slides API is not connecting to the script, which is preventing it from running any of the Slides related functions (create, append etc.)
I’ve tried all of these suggestions:
Enabling the Google Slides API service in Apps Script, from Services | Add a Service
Trying to run the script as a Standalone and a Container-Bound script
But I just can’t seem to catch a break.
Any help would be really appreciated!