Can you assign scripts to page elements (shapes etc.)?

后端 未结 2 1847
不思量自难忘°
不思量自难忘° 2021-01-24 03:52

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

相关标签:
2条回答
  • 2021-01-24 04:13

    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".

    0 讨论(0)
  • 2021-01-24 04:14

    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

    0 讨论(0)
提交回复
热议问题