Google脚本文档无法访问的错误-创建并尝试用代码打开文档 [英] Google Script Document Inaccessible Error - creating and attempting to open document in code

查看:63
本文介绍了Google脚本文档无法访问的错误-创建并尝试用代码打开文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些旧的代码在5年前非常有效,可以使用Google表单并从信息中填充预先设计的模板.我不需要一会儿使用它,但是现在我有一个类似的项目,并且正在尝试使过时的代码恢复活力.我有一个错误,我找不到或无法找到在线答案.请帮忙!

I had some old code that worked great 5 years ago in taking a Google Form and filling in a pre-designed template from the information. I haven't needed to use it in awhile, but now I have a similar project and was trying to revitalize the outdated code. I have one error I cannot figure out or find an answer to online. Please Help!

代码的相关部分是:

//创建模板的副本

  var copy = DriveApp.getFileById(docTemplate)
            .makeCopy(docName+' TEST ')
            .getId();

//打开临时文档

  var copyDoc = DocumentApp.openById(copy);

第一部分有效,在我的Google云端硬盘中创建了文档的副本,而var copy返回了新文档ID的值.

The first part works, a copy of the document is created in my Google Drive and var copy returns the value of the new document ID.

我收到错误消息无法访问该文档.请稍后再试.(第79行,文件代码")"

I get the error message "The document is inaccessible. Please try again later. (line 79, file "Code")"

第79行是:"var copyDoc = DocumentApp.openById(copy);".

line 79 of code is the : "var copyDoc = DocumentApp.openById(copy);".

我尝试了一些不同的代码来打开文件,它们都返回相同的错误消息.

I have tried a few different codes for opening a file and they are all returning the same error message.

推荐答案

只想分享我对这个问题的解决方案.我知道这是一个旧线程,但将来可能会有其他人偶然发现此线程,他们仍在尝试解决此问题.

Just want to share my resolution to this problem. I know is an old thread but there may be other people in the future who will stumble upon this thread who are still trying to fix this issue.

我刚才遇到此错误.事实证明,克隆后试图打开的文件是".docx"文件.文件.已上传到Google驱动器的MS Word文件.DocumentApp API仅可以打开google docs文件.要解决此问题,只需打开要克隆的基本文件,然后打开File>另存为Google文档.这将创建一个新文件.将该文件用作新的基本文件.

I encountered this error just now. It turns out that the file that was cloned and tried to open after was a ".docx" file. A MS word file that was uploaded to google drive. The DocumentApp API can only open google docs files. To fix this, just open the the base file that was being cloned then File > Save as Google Docs. This will create a new file. Use that as the new base file.

这篇关于Google脚本文档无法访问的错误-创建并尝试用代码打开文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆