2

I'm trying to write a function to delete notes from Google Slides presentation using Google Apps Script.

I went through the examples and assume I need to match that to something like https://developers.google.com/slides/samples/writing#delete_a_page_or_page_element by calling speakers notes using https://developers.google.com/slides/how-tos/notes, but I can't make the link.

New to Google Apps Script, any help appreciated.

1
  • Can you provide your current script? I think that it will help users think of your solution. Commented May 21, 2018 at 21:51

3 Answers 3

2

Thanks for the initial script! Unfortunately it didn't work for me, and after several attempts, I've made it work:

function clearNotes(){
    var presentation = SlidesApp.getActivePresentation();
    var presentationId = presentation.getId();
    var slides = presentation.getSlides();

    var requests = [];

    slides.forEach(function(slide, i) {
        var slideNote = slide.getObjectId(); 
        var slideNotesPage = slide.getNotesPage();
        var shape = slideNotesPage.getSpeakerNotesShape();
        var shapeText = shape.getText();

        if(shapeText != undefined){

           shapeText.clear();
        }
    })
    if(requests.length > 0){
        var batchUpdateResponse = Slides.Presentations.batchUpdate({requests: requests}, presentationId);
    }
}

As a newbie, it involved lots of try and error, debug and follow the guide here: https://developers.google.com/apps-script/reference/slides/text-range.html#clear()

So far, it's the only solution I've found to batch delete all notes in a Google Slides presentation.

Hope this helps, Rafa.

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

Comments

0

Here is how I did it.

function clearNotes(){
    var presentation = SlidesApp.getActivePresentation();
    var presentationId = presentation.getId();
    var slides = presentation.getSlides();

    var requests = [];

    slides.forEach(function(slide, i) {
        var slideNote = Slides.Presentations.Pages.get(presentationId, slide.getObjectId()); 
        var slideNoteId = JSON.parse(slideNote).slideProperties.notesPage.notesProperties.speakerNotesObjectId;

        var slideNotesPage = JSON.parse(slideNote).slideProperties.notesPage;
        var shapeText = slideNotesPage.pageElements[1].shape.text;

        if(shapeText != undefined){
        requests.push({
            deleteText: {objectId: slideNoteId,textRange:{type: 'ALL'}}
        });
        }
    })
    if(requests.length > 0){
        var batchUpdateResponse = Slides.Presentations.batchUpdate({requests: requests}, presentationId);
    }
}

Hope it helps.

Comments

0

Google has now integrated this option into the Slides program. When you make a copy you can choose/check to include notes or not.

Check boxes show options when creating copy of current Slides presentation

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.