如果您能提供有关如何修复此错误的指导,我们将不胜感激。请参阅下面给出错误的代码,
// 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);
最佳答案
感谢 Tanaike 和对代码的一些更改 - 这个问题已经解决。请参阅下面更新的代码。
// 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);
在getSlides()
之后使用[0]
肯定有帮助
我已删除 .duplicate()
因为它会在模板上创建重复项。
关于javascript - 类型错误 : Cannot read property 'insertSlide' of null (line 60, 文件 "Code"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60200617/