title: Create list of all sheet names in Google Apps Scripts
body: <h3>My goal</h3>
  
  <p>I have two spreadsheets, SpreadSheetA and SpreadSheetB.</p>
  
  <p>I am trying to get a list of the names of all the sheets in SpreadSheetA and add it to the active sheet in SpreadSheetB.</p>
  
  <h3>My progress so far</h3>
  
  <p>I have the code done but keep getting an error message when I run it.</p>
  
  <p>The error message is "Cannot convert Array to Object[][]" in reference to the line <code>range.setValues(sheetNameArray);</code>.  </p>
  
  <p>Here is my code:</p>
  
  <pre><code>function getSheetNamesAndAddToOtherSheet() {
    var spreadSheetAURL = "https://docs.google.com/spreadsheets/d/UNIQUE-ID-HERE/edit"; 
    var sheetNameArray = [];
  
    var spreadSheetsInA = SpreadsheetApp.openByUrl(spreadSheetAURL).getSheets();
  
    for (var i = 0; i &lt; spreadSheetsInA.length; i++) {
      sheetNameArray.push(spreadSheetsInA[i].getName());
    }
  
    var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var range = sheet.getRange(1, 1, sheetNameArray.length, 1);
    range.setValues(sheetNameArray);
  }
  </code></pre>