I'm really new to programming in Google Apps Script and I'm trying to replace some words in all my slides with some text from a spreadsheet. I was following an internet tutorial for a similar task, but for replacing data in a Google Docs. I thought it would be the same, but it isn't and I'm kinda lost now. I need to 'translate' this piece of code from Docs to replace text in Slides.
var doc = DocumentApp.openById(copy.getId());
var body = doc.getBody();
body.replaceText('name', name);
body.replaceText('adress', adress);
body.replaceText('date', date);
I know I read the slide by this:
var presentation = Slides.Presentations.get(copy.getId());
But I don't know how to do the same task from before, but with my slides. Can someone help?
Edit: I tried what @Kos suggested. Since I have to replace about 20 words, I tried to implement a for loop, but I still don't get my words replaced in the slide.
var dict = {'{{word1}}':word1,'{{word2}}':word2};
for(let i=0; i< dict.length; i++){
const resource = {
requests: [{
replaceAllText: {
replaceText: dict[dict[i]],
containsText: { matchCase: true, text: dict[i] }
}
}]
};
Slides.Presentations.batchUpdate(resource, presentation.getId());
}
Should I try a different approach for replacing these words?