2

I need to have a note created with Google Apps Script in a presentation on slide 0 where it is having a hyperlink, which I grab off a Google Sheet, attached to it. It needs to be a note not a text or image in a slide. Reason being, that URL's are only "clickable" in a slide if the presentation is put into presentation mode first.

If I do it manually, I can create a notes text, select it and attach a hyperlink. The text changes to a regular hyperlink appearance, which one can click without first of all going to presentation mode.

This is how far I came for now:

slides[0].getNotesPage().getSpeakerNotesShape().getText().setText("juhu");

But how to add the hyperlink, in this example to the string "juhu"?

If I am trying to get it done with: .setLinkUrl() it tells me:

Exception: The operation is not allowed on notes page element (g7185420b90_2_454). (line 19, file "Code")

Any ideas?

2 Answers 2

1

My understanding of your requirements:

  • You want to put the text with the hyperlink to the note page on Google Slides.
  • You want to achieve this using Google Apps Script.

In this answer, Slides service is used.

Modification points:

  • setLinkUrl() is the method of Class TextStyle.
    • From your question, when slides[0].getNotesPage().getSpeakerNotesShape().setLinkUrl(url) is run, such error occurs. I think that the reason of your issue might be this.
  • In order to set the hyperlink to the text, at first, please use getTextStyle() to the object of TextRange. This method returns the object of TextStyle.

Modified script:

When your script is modified, it becomes as follows.

var text = "juhu";
var url = "###";  // Please set the URL.

var slides = SlidesApp.getActivePresentation().getSlides();
var text = slides[0].getNotesPage().getSpeakerNotesShape().getText().setText(text);
text.getTextStyle().setLinkUrl(url);

or

var text = "juhu";
var url = "###";  // Please set the URL.

var slides = SlidesApp.getActivePresentation().getSlides();
slides[0].getNotesPage().getSpeakerNotesShape().getText().setText(text).getTextStyle().setLinkUrl(url);

References:

Sign up to request clarification or add additional context in comments.

1 Comment

@Thomas Holst Thank you for replying. I'm glad your issue was resolved.
0

You need to turn on Advanced Slides Service, then use next code to set slide's notes link:

let presentationId = SlidesApp.getActivePresentation().getId();
let presentation = Slides.Presentations.get(presentationId);

let slidesReqs = [];

slidesReqs.push({
  updateTextStyle: {
    objectId: presentation.slides[0].slideProperties.notesPage.notesProperties.speakerNotesObjectId,
    style: {
      link: {
        url: 'https://example.com'
      }
    },
    textRange: {
      type: 'ALL'
    },
    fields: 'link'
  }
});

Slides.Presentations.batchUpdate({'requests': slidesReqs}, presentationId);

Result:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.