TypeError: Cannot read property 'insertSlide' of null (line 60, file "Code")

TypeError: Cannot read property 'insertSlide' of null (line 60, file "Code")

如能提供有关如何修复此错误的任何指导,我们将不胜感激。请看下面给出错误的代码,

  // 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);

使用 [0]getSlides()

之后肯定有帮助

我已删除 .duplicate(),因为它会在模板上创建重复项。