【问题标题】:Copy of document created through DriveApp is not accessible through DocumentApp通过 DriveApp 创建的文档副本无法通过 DocumentApp 访问
【发布时间】:2018-10-28 13:43:10
【问题描述】:

以下 Google 脚本因错误而失败 -

文档丢失(可能它已被删除,或者您没有读取权限?)

在线var body = DocumentApp.openById(NewdocumentId).getBody(); 下面的代码。

我正在从同一帐户/脚本运行代码,新文档副本正在生成,然后尝试访问它发生错误,我在这里缺少什么???

  //Copy the template to new folder
  var NewdocumentId = DriveApp.getFileById('MyValidDocIDHere').makeCopy().getId();
  DriveApp.getFileById(NewdocumentId).setName(row_no + '_' + customer.checkout+ '_' + customer.name + '_' + customer.room);
  Utilities.sleep(9000);
  var body = DocumentApp.openById(NewdocumentId).getBody();
  body.replaceText("##DATE##", customer.checkin);
  NewdocumentId.saveAndClose();

【问题讨论】:

  • 您可以访问'MyValidDocIDHere' 吗?

标签: google-apps-script google-sheets google-drive-api google-apps


【解决方案1】:

我找到了解决方案,因为这是要使用的 Google 表格 SpreadsheetApp.openById 而不是 DocumentApp.openById,互联网上的一些旧示例让我复制了这个错误:(

【讨论】:

    猜你喜欢
    • 2015-03-14
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    • 2021-07-06
    • 1970-01-01
    • 2021-12-15
    • 2014-08-23
    • 2018-12-04
    相关资源
    最近更新 更多