Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception: Service Spreadsheets failed while accessing document with id

Google Script can't access to a spreadsheet created by it, but can open a spreadsheet created by me.

This is working (the spreadsheets were created by me):

var DataBookID = MasterSheet.getRange("B4:G5").getValue();   
var Data = SpreadsheetApp.openById(DataBookID);

This is not working (spreadSheet duplicated via google script):

var WorkingBook = SpreadsheetApp.openById(DuplicateID);

The error I received: Error
Exception: Service Spreadsheets failed while accessing document with id -----Spreadsheet ID------.

The duplicate method:

//DUPLICATE TEMPLATE
var destFolder = DriveApp.getFolderById(DestFolderID);
DriveApp.getFileById(TemplateID).makeCopy(BookName, destFolder);

EDIT: If I try this, it gives me the same error:

var testing = DriveApp.getFileById(TemplateID).makeCopy(BookName, destFolder);
SpreadsheetApp.open(testing).getRange("A8").setValue("AAAAAA");

I don't know why it gives me this error. Thanks in advance.

like image 888
Duxi Avatar asked Jun 13 '26 01:06

Duxi


1 Answers

SOLVED, just I have to save the template file as a google spreadsheet document (it was xlsx) and now works.

like image 142
Duxi Avatar answered Jun 17 '26 23:06

Duxi