我有一个有效的代码...有时......随机,它在运行时停止并给我这个错误。我很乐意提供代码,但我只是认为可能有一个明确定义此错误消息的含义。编辑 - 事实上,我已经添加了下面的脚本。
function onOpen() {
var folder = DriveApp.getFolderById("0098230948YUIAEr80w9er");
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1")
sheet.clearContents();
sheet.appendRow(["pp","v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10", "v11", "v12"]);
sheet.setFrozenRows(1);
var files = folder.getFiles();
while (files.hasNext()) {
var file = files.next();
var otherSheet= SpreadsheetApp.open(file).getSheetByName("Project Overview");
var data = otherSheet.getRange("B3:I30").getValues();
var v1 = data[1][0];
var v2 = data[2][0];
var v3 = data[0][0];
var v4 = data[4][0];
var v5 = data[5][0];
var v6 = data[8][0];
var v7 = data[3][0];
var v8 = data[14][0];
var v9 = data[1][7];
var v10 = data[2][7];
var v11 = data[3][7];
var v12 = data[0][7];
var url = file.getUrl();
var name = "Site Detail";
var semi = ";";
var hyp = "=hyperlink(\"";
var quot = "\"";
var clos = ")";
var pp = hyp + url + quot + semi + quot + name + quot + clos;
if (Status != 'Those' && Status != 'This' && Status != 'That' && Status != 'Other')
{ sheet.appendRow([pp,v1, v2, v3, v4, v5, v6, v7, v8, v9,v10,v11,v12])
sheet.sort(2);}
}}
答案 0 :(得分:3)
因此,将脚本更改为此工作:
var files = folder.getFiles();
while (files.hasNext()) {
var file = files.next();
Utilities.sleep(200);
我不能告诉你为什么,除此之外,我怀疑它允许脚本赶上"在移动到下一个文件之前自己。我希望这对某人有帮助,如果有人可以向我们所有人解释为什么这样做,我会很高兴。