问题
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);
回答1:
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.
来源:https://stackoverflow.com/questions/60200617/typeerror-cannot-read-property-insertslide-of-null-line-60-file-code