Home > Back-end >  Exception: Service Spreadsheets failed while accessing document with id
Exception: Service Spreadsheets failed while accessing document with id

Time:04-26

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.

CodePudding user response:

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

  • Related