Reputation: 430
Would be grateful for any guidance on how to fix this error. Please see below code which gives the error,
// Copy a slide from another presentation and inserts it.
var otherPresentation = SlidesApp.openById('1Fz6YWCyLIdHfDoonz-40qRlmnNCWwROIQjXqYwmRxS8');
var currentPresentation = SlidesApp.getActivePresentation();
var slide_v1 = otherPresentation.getSlides[0];
var insertionIndex = 1;
currentPresentation.insertSlide(insertionIndex, slide_v1);
Upvotes: 0
Views: 345
Reputation: 430
Thanks to Tanaike and some changes to the code - this has been solved. Please see updated code below.
// Copy a slide from another presentation and inserts it.
var otherPresentation = SlidesApp.openById('1Fz6YWCyLIdHfDoonz-40qRlmnNCWwROIQjXqYwmRxS8');
var currentPresentation = SlidesApp.openById(documentId);
var slide_v1 = otherPresentation.getSlides()[0];
var insertionIndex = 1;
currentPresentation.insertSlide(insertionIndex, slide_v1);
Using [0]
has definitely helped after the getSlides()
I have removed .duplicate()
because it creates duplicates on the template.
Upvotes: 1