0

I have a template sheet that imports several ranges across several hidden data sheets.

Using Google Apps Script, I am planning on regularly making copies of this template:

let template = DriveApp.getFileById(id);
let newTemplate = template.makeCopy();
newTemplate.setName(`${variable} - Doc Name`);

However, as there are several ranges that have been imported (using =IMPORTRANGE) I would need to go in and manually "allow access" to link each sheet to the reference sheet after a duplicate has been made. Is there a way to automate this in Google Apps Scripts WITHOUT opening my sheet up to the general public (anyone who has the link)?

YangTegap
  • 381
  • 1
  • 11
  • That is only possible by making the source spreadsheets shared with anyone with the link or on the web. – Rubén Jul 06 '21 at 19:39
  • I tried that, just to test it out, and it still asked me to allow access when I made a copy... – YangTegap Jul 06 '21 at 19:42
  • Authorizing ImportRange does not alter access permissions to the residing spreadsheet, but rather the action simply allow data to be imported. To change access rights, use the Share button's UI or change which folder the spreadsheet copies are located at. –  Jul 06 '21 at 19:42
  • @User86530 I changed the access rights to "Anyone with the link" both using the UI and using Google apps script, but both times it asked me to link the sheets still, after I made a copy. Could this be because I am using the same owner account to open the new duplicate sheet? – YangTegap Jul 06 '21 at 19:45
  • @AMcGuffin ImportRange will always need to be relinked on any spreadsheet copies. –  Jul 06 '21 at 19:46
  • What spreadsheet did you shared with anyone with the link, the one holding the IMPORTRANGE formula or the spreadsheet that holds the data to be imported? Are you using a Google common account or Google Workspace account? – Rubén Jul 06 '21 at 19:48

0 Answers0