title: Google script google sheet to calendar TypeError: Cannot find function createEvent in object Calendar. (line 18, file "Code")
body: <p>I have attempted to create a google script that will create calendar events based on information within cells in google sheets. I have gotten to the point where everything is labeled and marked, but an error is occuring that states:</p>
  
  <blockquote>
    <p>TypeError: Cannot find function createEvent in object Calendar. (line 18, file "Code")</p>
  </blockquote>
  
  <p>Here is the code I have written:</p>
  
  <pre><code>function calInsert() {
    var sheet = SpreadsheetApp.getActiveSheet();
    var startRow = 2;  // First row of data to process
    var numRows = 25;   // Number of rows to process
    var dataRange = sheet.getRange(startRow, 2, numRows, 9);
    var data = dataRange.getValues();
    var cal = CalendarApp.getCalendarsByName( "EC Calendar" );
    for (i in data) {
      var row = data[i];
      var title = row[1];  // First column
      var tstart = row[2]; // Second column
      var tstop = row[3];
      var desc = row[4];       
      var loc = row[5];
      var cmmail = row[6];
      var leamail = row[7];
  
    var event = cal.createEvent(title, new Date(tstart), new Date(tstop), {description:desc,location:loc,guests:cmmail,guests:leamail}); 
  </code></pre>
  
  <p>}
  }</p>
  
  <p>Any help you can provide would be appreciated.</p>