2023-01-21

insertChart throws exception: Service Spreadsheets failed while accessing document with id

I'm trying to copy a chart from one spreadsheet (spreadsheet_a_id) to another using the following code:

function copy_chart() {
  var chart_sheet = SpreadsheetApp.openById(spreadsheet_a_id).getSheetByName("Sheet1");
  var chart = chart_sheet.getCharts()[0];
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  ss.getActiveSheet().insertChart(chart);  // Line fails
}

However, the line ss.getActiveSheet().insertChart(chart); throws the following exception:

Exception: Service Spreadsheets failed while accessing document with id ***

What would be the reason for that?



No comments:

Post a Comment