title: function to name range google app script
body: <p>I'm very new to this so I apologize for any missing info in advance. I am trying to make a function that sets a range in any document I use it in. Here is my code at the moment:</p>
  
  <pre><code>function nameRangeDocDate() {
  
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheetByName("Logs");
  
  var rangeToName = sheet.setRange(1,1);
  var rangeName = "DocDate";
  
  ss.sheet.setNamedRange(rangeName, rangeToName)
  
  }
  </code></pre>
  
  <p>Whenever I run the function I get the message: "TypeError: Cannot call method "setRange" of null. (line 6, file "we")". Can anyone explain to me what is wrong with my code? Am I missing something or is my code just wrong? </p>