TypeError:无法读取null的属性"insertSlide"(第60行,文件“代码") [英] TypeError: Cannot read property 'insertSlide' of null (line 60, file "Code")

查看:152
本文介绍了TypeError:无法读取null的属性"insertSlide"(第60行,文件“代码")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常感谢您提供有关如何纠正此错误的指导.请参见以下给出错误的代码,

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

推荐答案

感谢Tanaike和代码的一些更改-已经解决.请在下面查看更新的代码.

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

getSlides()

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

I have removed .duplicate() because it creates duplicates on the template.

这篇关于TypeError:无法读取null的属性"insertSlide"(第60行,文件“代码")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆