google-apps-script - DocumentApp 服务抛出“访问带有 id 的文档时服务文档失败”错误
问题描述
我正在为 Google Docs 创建一个脚本,该脚本从我所在的当前文档中获取每个元素并将其复制到另一个文档中(基本上是制作副本)。
duplicateDocument();
function duplicateDocument() {
var currentDoc = DocumentApp.getActiveDocument().getBody();
var targetDoc = DocumentApp.create('Speech Doc');
var totalElements = currentDoc.getNumChildren();
//Goes through each type of element to preserve formatting
for( var index = 0; index < totalElements; ++index ) {
var body = targetDoc.getBody();
var element = currentDoc.getChild(index).copy();
var type = element.getType();
if( type == DocumentApp.ElementType.PARAGRAPH ){
body.appendParagraph(element);
}
else if( type == DocumentApp.ElementType.TABLE){
body.appendTable(element);
}
else if( type == DocumentApp.ElementType.LIST_ITEM){
body.appendListItem(element);
}
else if( type == DocumentApp.ElementType.BOOKMARK ){
body.appendBookmark(element);
}
}
}
一旦我调用该函数,就会弹出此错误:
访问 ID 为 [目标文档 ID] 的文档时服务文档失败
这段代码在一两天前就起作用了……什么给出了?
解决方案
推荐阅读
- r - 在不断变化的 plot_ly 动画中映射颜色
- javascript - Click 事件适用于 jQuery,但不适用于 Vanilla JS
- ant - 调用 ant exec 命令给出文件未找到错误
- python - 对于熊猫中其他两列的相同值,如何用同一列的非缺失值填充缺失值?
- reactjs - react-google-login 在 react-web-view 上没有工作
- html - 引导弹出框间距
- c# - 从一个位置访问代码中的潜在更改
- c# - C# - Dictionary 和 Object[] 之间的三元运算符
- java - Apache Camel 多条 SQL 语句
- image - 在锚标签图像中添加变焦镜头功能