无法通过 DocumentApp 访问通过 DriveApp 创建的文档副本

Copy of document created through DriveApp is not accessible through DocumentApp

下面的 Google 脚本因错误而失败 -

Document is missing (perhaps it was deleted, or you don't have read access?)

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

我是 运行 来自同一个 account/script 的代码正在生成新文档副本,然后尝试访问它时发生错误,我在这里缺少什么???

  //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();

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