Consulting

Results 1 to 3 of 3

Thread: Updating Google Calendars from a Google Spreadsheet

  1. #1

    Updating Google Calendars from a Google Spreadsheet

    I’ve been trying to run a script in order to sync my google spreadsheet with my google calendar, however, I get the error message: Cannot find method createEvent(string,string,string,object). (line 15, file "Code")

    The script that I entered is:
    HTML Code:
    function caltest1() {
      var sheet = SpreadsheetApp.getActiveSheet();
      var startRow = 2; 
      var numRows = 199;  
      var dataRange = sheet.getRange(startRow, 1, numRows, 5);
      var data = dataRange.getValues();
      var cal = CalendarApp.getDefaultCalendar();
      for (i in data) {
        var row = data[i];
        var title = row[2]; 
        var desc = row[3];      
        var tstart = row[1];
        var tstop = row[1];
        var loc = row[3];
        cal.createEvent(title, tstart, tstop, {description:desc,location:loc});
    }
    }
    There is a total of 199 rows not including the header row. I have date/time in the first row, the event in the second, and the country where the event is taking place in the third column. Can you let me know how I can run this so it imports all the events into a google calendar I have created and updates automatically when new events are entered into the spreadsheet? The google spreadsheet was from an excel file I imported.
    Last edited by Aussiebear; 12-31-2024 at 04:16 PM.

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,476
    Location
    Maybe not the best Forum for this question.
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    There's a no-script alternative to this called Automate.io. But there's a catch. - it can only add new rows to your calendar.

    https://automate.io/integration/goog.../google-sheets

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •