README Create Calendar Event #
What this does #
Creates an event in the authenticated user’s default Outlook/M365 calendar via the Microsoft Graph /me/events endpoint, using OAuth2 with MFA. Supports subject, start and end date/time, optional attendees (comma- or semicolon-separated SMTP addresses), optional location or online Teams meeting, and optional plain text body. The local Windows timezone is read from the registry and passed to Graph in the format it expects, ensuring events are created in the correct timezone without manual configuration.
Office apps #
- Access (tested M365)
- Excel (untested M365)
Required components #
- VBAuth.dll v1.x
- modVBAuthGlobalConstants.bas (from /shared)
- modCreateCalendarEvent.bas (this module)
Azure Entra App Registration #
Delegated permissions:
- Calendars.ReadWrite
VBAuth Admin Table – Required Values #
| Column Name | Required Value / Example | Notes |
|---|---|---|
| AppID | User-defined (8 in the feature demo database) | Identity column used for record selection |
| ActionName | VBAuth – Create Calendar Event | Logical action name |
| ClientID | as per Azure Entra App | Application (client) ID |
| TenantID | as per Azure Entra App | Directory (tenant) ID |
| ObjectID | (your Object ID) | Set by PopulateMissingObjectIDs |
| ScopeClaims | Calendars.ReadWrite | Comma-separated Graph scopes |
| Verb | POST | HTTP verb |
| URLPart1 | https://graph.microsoft.com/v1.0/me/events | Graph endpoint |
| URLParameter1 | NO VALUE REQUIRED | Not used |
| URLPart2 | NO VALUE REQUIRED | Not used |
| URLParameter2 | NO VALUE REQUIRED | Not used |
| URLPart3 | NO VALUE REQUIRED | Not used |
| WaitForLogin | 60 | Seconds — NB MSXML2 timeout parameters are in milliseconds |
Module: modCreateCalendarEvent.bas #
Public functions #
CreateCalendarEvent(dtStart As Date, dtEnd As Date, strSubject As String,
strAttendees As String, strLocation As String,
blnTeams As Boolean, strBody As String,
ByRef strMessage As String) As Boolean
Code language: JavaScript (javascript)
Acquires a bearer token for the configured AppID, builds the JSON payload, and POSTs to the Graph /me/events endpoint. Returns True on HTTP 201 (Created). Returns False on any other HTTP status or error, with strMessage containing the error detail.
strAttendees accepts a comma- or semicolon-separated list of SMTP addresses. Pass an empty string to create an event with no attendees. Each attendee is added as a required attendee — Graph sends meeting invitations automatically.
blnTeams — when True, adds an online Teams meeting to the event by setting isOnlineMeeting: true and onlineMeetingProvider: "teamsForBusiness" in the payload. Pass False for an in-person or no-location event. blnTeams and strLocation are independent — both can be set simultaneously.
Private functions #
GetWindowsTimeZoneName() As String
Code language: JavaScript (javascript)
Reads the Windows timezone key name from the registry (HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation\TimeZoneKeyName). Returns the value in the exact format Microsoft Graph expects (e.g. GMT Standard Time, Eastern Standard Time). Falls back to UTC if the registry read fails.
FormatGraphDateTime(dtValue As Date) As String
Code language: JavaScript (javascript)
Formats a VBA Date value as an ISO 8601 datetime string (yyyy-MM-ddTHH:mm:ss) for the Graph API dateTimeTimeZone type.
EscapeJsonString(strInput As String) As String
Code language: JavaScript (javascript)
Escapes characters that are special in JSON strings: backslash, double-quote, CR/LF, and tab.
BuildAttendeesJson(strAttendees As String) As String
Code language: JavaScript (javascript)
Converts a comma- or semicolon-separated list of SMTP addresses into the Graph API attendees array JSON fragment. Returns an empty string if strAttendees is blank, in which case the attendees field is omitted from the payload entirely. Each address is added as a required attendee type.
BuildCreateEventPayload(dtStart, dtEnd, strSubject, strAttendees,
strLocation, blnTeams, strBody) As String
Code language: JavaScript (javascript)
Constructs the JSON request body for POST /me/events. strAttendees, strLocation, and strBody are optional — they are omitted from the payload if passed as empty strings. When blnTeams is True, isOnlineMeeting: true and onlineMeetingProvider: "teamsForBusiness" are included in the payload.
Behaviour #
- Creates the event in the authenticated (signed-in) user’s default calendar — not in a shared or delegate calendar
- Graph returns HTTP 201 on success with the full event object in the response body (the response body is not parsed by this module)
- Start and end date/times are passed with the local Windows timezone name — events appear in the correct timezone in Outlook regardless of where the user views them
- When attendees are supplied, Graph sends meeting invitation emails automatically on creation
- A network timeout returns a descriptive error message — timeout duration is controlled by
lngHTTPTimeoutinmodVBAuthGlobalConstants.bas - Special characters in subject, location, body, and attendee addresses are escaped automatically before the payload is built
- Requires interactive sign-in — application permissions are not supported
Notes #
- Does not support application permissions
- Attendees, location, and body are all optional — pass an empty string for any field not required
blnTeamsandstrLocationare independent — an event can have both a physical location and a Teams link simultaneously- The Graph API does not support creating recurring events via this module — only single-instance events are created
- Admin consent must be granted for
Calendars.ReadWritein the Azure portal before users can authenticate - The Graph API returns HTTP 201 on success, not HTTP 200 — callers must check for 201
VBAuth, developed and maintained by Andrew Richards (The IT Service Ltd) and Peter Bryant (Corylus Business Systems), © 2025–2026. All rights reserved. https://vbauth.com