I want to make an interactive slideshow for students.
I want to add shapes, so when you click on the shape it will run an Apps Script script. This is possible in Google S
At this time it's not possible on Google Slides.
The guide about Custom Menus only mention that scripts could be assigned to shapes on Google Sheets. It doesn't mention that this is possible in Google Slides.
Other documents says that the Slides service "allows scripts to create, access, and modify Google Slides files", by the other hand the Slides API "lets you create and modify Google Slides presentations".
There is no way to run a container-bound script by clicking a shape in Google Slides like you can in Google Sheets. But, you can accomplish a similar effect by adding a shape with a link to a web app that runs your script when opened. For Example, here is a script for a web app that changes the text on the first shape of the first slide whenever someone visits it.
function doGet() {
const presentation = SlidesApp.openById(id); // presentation id
const slide = presentation.getSlideById(id); // slide id
const textBox = slide.getShapes().filter(_s => _s.getObjectId() === objectId)[0].getText(); // id of your text box object
const clicks = Number(textBox.asString());
textBox.setText(clicks + 1);
return ContentService.createTextOutput("Thanks for clicking!"); //message to display when user visits your webapp
}
Here is a working example: Google Slide Presentation with Clickable Button