title: Google Spreadsheet Custom Menu Returned Script Function Not Found
body: <p>I am trying to add a custom menu to the google spreadsheet editor's interface to activate a script by Tony Hirst to pull calendar events into the spreadsheet.</p>
  
  <p>By when I click on the custom menu option, it returned "script function not found: GetCalendar()"</p>
  
  <p>I have tried to make modifications and read the google documentation but am not sure what I am doing wrong.</p>
  
  <p>Thank you.</p>
  
  <pre><code>/**
  * A custom function that gets the calendar events by calendar ID.
  */
  function GetCalendar() {
  // get the spreadsheet object
  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  // set the second sheet as active
  SpreadsheetApp.setActiveSheet(spreadsheet.getSheets()[1]);
  // fetch this sheet
  var sheet = spreadsheet.getActiveSheet();
  
  //http://www.google.com/google-d-s/scripts/class_calendar.html#getEvents
  // The code below will retrieve events between 2 dates for the user's default calendar and
  // display the events the current spreadsheet
  var calId = "SpecificCalendarID";
  var cal = CalendarApp.getCalendarById(calId);
  var events = cal.getEvents(new Date("June 15, 2015"), new Date("March 20, 2080"));
  for (var i=0;i&lt;events.length;i++) {
  //http://www.google.com/google-d-s/scripts/class_calendarevent.html
  var details=[[events[i].getTitle(), events[i].getDescription(), events[i].getStartTime()]];
  var row=i+2;
  var range=sheet.getRange(row,1,1,3);
  range.setValues(details);
    }
  }
  
  /**
  * A function that runs when the spreadsheet is open, used to add a
  * custom menu to the spreadsheet.
  */
  function onOpen() {
  var ui = SpreadsheetApp.getUi();
  var menuItems = ui.createMenu ('Custom Menu');
  menuItems.addItem ('Get Events','GetCalendar()');
  menuItems.addToUi();
  }
  </code></pre>