首页 > 解决方案 > 我可以使用带有 VBA 的 goole 日历 API(从 MS-Excel 创建日历条目)

问题描述

我喜欢从 Microsoft Excel 2016 创建一个新的谷歌日历条目,我该怎么做?

我尝试了以下代码,但在“xmlhttp.send ...”处出现超时。

Sub AddGoogleKalenderEntry()
    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
    xmlhttp.Open "POST", "https://www.google.com/accounts/ClientLogin", False
    xmlhttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    xmlhttp.send "accountType=HOSTED_OR_GOOGLE&Email=<User>@gmail.com&Passwd=<PWD>" & "&source=Gulp-CalGulp-1.05&service=cl"

    Lines = Split(xmlhttp.responseText, vbLf)
    nvp = Split(Lines(2), "=")

    Set xmlhttp = Nothing

    calentry = "<?xml version='1.0' ?><entry xmlns='http://www.w3.org/2005/Atom' " _
    & "xmlns:gd='http://schemas.google.com/g/2005'>" _
    & "<category scheme='http://schemas.google.com/g/2005#kind' " _
    & "term='http://schemas.google.com/g/2005#event'></category>" _
    & "<title type='text'>Tennis with Beth</title>" _
    & "<content type='text'>Meet for a quick lesson.</content>" _
    & "<gd:transparency " _
    & "value='http://schemas.google.com/g/2005#event.opaque'>" _
    & "</gd:transparency>" _
    & "<gd:eventStatus " _
    & "value='http://schemas.google.com/g/2005#event.confirmed'>" _
    & "</gd:eventStatus>" _
    & "<gd:where valueString='Rolling Lawn Courts'></gd:where>" _
    & "<gd:when startTime='2010-01-22T15:00:00.000Z' " _
    & "endTime='2010-01-22T17:00:00.000Z'></gd:when>" _
    & "</entry>"

    url = "http://www.google.com/calendar/feeds/default/private/full"

    Call postEntry(url, nvp)


End Sub

标签: vbagoogle-calendar-api

解决方案


推荐阅读