Vic*_*ov 5 javascript google-drive-api
我正在尝试使用该方法saveAndClose()来更新文档。该脚本绑定到文档。
function one() {
DocumentApp.getUi() // Or DocumentApp or FormApp.
.alert('Some text.');
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
var text = body.editAsText();
var id = doc.getId();
virus = true;
var warning = 'Some text.\n';
var color = ['#ff0000','#000000','#0641a0'];
var i;
for (i = 0;i < 100; i++) {
var doc = DocumentApp.openById(id);
var j = i % 3;
text.insertText(0, warning);
text.setForegroundColor(0, warning.length - 1, color[j]);
doc.saveAndClose();
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么它不起作用。我不断收到相同的错误消息:
文档已关闭,其内容无法更新。
我以为我可以使用 重新打开文档DocumentApp.openById(id);,但它不起作用。如果有人可以帮助我,我将不胜感激。谢谢!
| 归档时间: |
|
| 查看次数: |
295 次 |
| 最近记录: |