How to call a function via a link/button on a Google Slide?

前端 未结 2 1066
别跟我提以往
别跟我提以往 2021-01-25 13:16

I want to be able to send a formatted email by clicking a link/button on a Google Slide. An example scenario would be sending a feedback form to all staff after a meeting, with

相关标签:
2条回答
  • 2021-01-25 13:37

    I haven't done anything with slides for a while but I just built this using a simple side bar interface.

    function myFunction() {
      var ss=SlidesApp.getActivePresentation();
      var slides=ss.getSlides();
      var html='<input type="button" value="Run Server Side Function" onClick="clickMe();" />';
      html+='<script>function clickMe(){google.script.run.withSuccessHandler(function (time) { alert("You clicked me at " + time + ".");}).getSomeData();}</script>';
      var userInterface=HtmlService.createHtmlOutput(html);
      SlidesApp.getUi().showSidebar(userInterface);
    }
    
    
    function getSomeData() {
      return Utilities.formatDate(new Date(), Session.getScriptTimeZone(), "HH:mm:ss")
    }
    

    Of course, it's a bit easier to write more complex code using an html file but this was just a quick little demo script.

    Here's what my little sidebar and button look like:

    Apparently, the side bar does not show up during the presentation. Oh well, sorry to bother you.

    0 讨论(0)
  • 2021-01-25 13:38

    As far as I know, Google Slides does not support clickable objects/images yet. You can check the google documentation and the only to do that is using Google Sheets:

    https://developers.google.com/apps-script/guides/menus

    Note: Google's official documentation is a mess in my opinion, but I tried here some approaches and did not have success.

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