2

I have a google slide desk with three slides & i want to add a comment to each slide. I am able to reach to the slide using for loop (total rows in sheet is same as total number of slides, and slide i am using is the second slide onwards. so there is no problem with my loop)

 // open the slide using slide id
 var s=SlidesApp.openById(a.getId())
 for(let r=2; r<=4; r++){
    // get the current slide
    var currentSlide=s.getSlides()[r-1];
    var fileId = currentSlide.getObjectId();
    var slideUrl = a.getUrl()+"#slide=id."+fileId;
    var slideId = getIdFromUrl(slideUrl);
    var comment = {'content':'hi'};
    Drive.Comments.insert(comment, slideId);
  }

function getIdFromUrl(url) { return url.match(/[-\w]{25,}/); }

This code works but its adding the comment to the file and not to the individual slide. (*Note - For this code to work, we have to enable Drive in services in app script.) How can i add the comment to the individual slides.

santoshaa
  • 173
  • 2
  • 4
  • 10

1 Answers1

5

Answer:

Not possible.

Explanation:

It is currently not possible to add comments to a specific location in Google Documents (including Docs, Sheets, Slides). The ability for adding anchored comments refers to non-Google Docs (e.g. images, PDFs) (listen to this video for more details).

Therefore, you can only add comments unanchored comments, belonging to the whole file.

What's possible is responding to a located comment by retrieving its id and calling Replies: create.

Issue Tracker:

There are several feature requests for this in Issue Tracker, either about all of Google Docs editors or about a specific editor:

I'd suggest you to subscribe to some or all of these issues by starring them and/or file a new feature request to tackle Slides specifically.

Related questions:

Iamblichus
  • 18,540
  • 2
  • 11
  • 27