1

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 the link on the very last slide.

I already have the code for the email in Google Script and it works perfectly fine when I run it (I also have an HTML file for the format), but I cannot find a way to run it via a link/button on a slide.

I would rather not run it every time the slide is open, only when a special link/button is clicked. Is there a way in Google Script where I can do this in Slides? Any help, method, suggestion is greatly appreciated!

Edit: The sidebar solution works for me! Can't believe I didn't think of it before but thank you very much!

Kirkland
  • 13
  • 4
  • Possible duplicate of [Google Slides API activating script on click of element](https://stackoverflow.com/questions/47919495/google-slides-api-activating-script-on-click-of-element) – dwmorrin Aug 05 '19 at 22:32
  • You could put your button on a sidebar. – Cooper Aug 05 '19 at 23:06
  • ! ! ! ! ! ! ! See - Star - Comment in Issue tracker! ! ! ! ! ! ! "Page elements on Slides should be selectable to run scripts like the shapes and images in spreadsheet" https://issuetracker.google.com/issues/186214943 "Presentation mode in slides should fill window not device" https://issuetracker.google.com/issues/186204484 – aNewb Apr 24 '21 at 23:44

2 Answers2

1

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.

Ricardo Cunha
  • 2,013
  • 6
  • 24
  • 42
1

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:

enter image description here

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

Community
  • 1
  • 1
Cooper
  • 59,616
  • 6
  • 23
  • 54