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!
The relevant part of the code is:
//Create a copy of template
var copy = DriveApp.getFileById(docTemplate)
.makeCopy(docName+' TEST ')
.getId();
// Open the temporary document
var copyDoc = DocumentApp.openById(copy);
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.
I get the error message "The document is inaccessible. Please try again later. (line 79, file "Code")"
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.
copy
is getting reset or redefined between these two lines of code? – Amygdalin