google-apps-script - 如何修复 "Exception: Unexpected error while getting the method or property open on object SpreadsheetApp"?

标签 google-apps-script google-sheets

我只粘贴了我试图单独运行的部分代码。

function myFunction() {
   var files = DriveApp.searchFiles('title contains "Companies_OHLC_0"');
   while (files.hasNext()) {
        var spreadsheet = SpreadsheetApp.open(files.next());
    }
 }

它曾经工作过一段时间,但我现在不断收到此异常:

Exception: Unexpected error while getting the method or property open on object SpreadsheetApp. (line 4, file "Code").

最佳答案

我明白了。 我有多个同名文件,因此,我遇到了这个异常。

我运行了其他脚本,这些脚本创建了具有相同名称的新文件。我没有注意到这一点。我删除了所有重复的文件,并且不再遇到此异常。

关于google-apps-script - 如何修复 "Exception: Unexpected error while getting the method or property open on object SpreadsheetApp"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62964344/

相关文章:

google-apps-script - 如何使用 Google Apps 脚本从 Google 工作表单元格获取错误消息?

google-apps-script - Google Sheet 将行复制到新工作表 IF 公式触发器

google-apps-script - 将字符串插入到工作表会导致插入的数字

javascript - 不断收到电子邮件: Cannot read property "0" from undefined

javascript - 过滤应用程序脚本中是否存在多个子字符串

javascript - Google 电子表格脚本 - 获取日期作为数字

google-apps-script - 如何使用 Google App Script 合并 Google 电子表格中的多个标签?

google-apps-script - 如何将谷歌电子表格侧边栏的输入发送到工作表脚本函数中?

javascript - 谷歌脚本超时

javascript - 如何使用谷歌脚本在字符串中查找文本?