This question is from an administrator who is looking for a way to create birthday events on a personal calendar, from contacts stored in shared folders.
We want the birthdays of contacts stored in a public contact folder appear in a user's personal calendar so the birthdays sync with their phone. There are approximately 3,000 contacts in this public folder, so any solution that requires touching each contact by hand won't work.
If you add a birthdate (or Anniversary date) to a contact in a Public Folder, Outlook will ask if you want to create a birthday event on your personal calendar. While this works fine for a few contacts, it's a lot of work when there is a large number of contacts, definitely not a good solution for 3000 contacts.
You can use a macro to check the contacts for a birthdate and create a recurring event on your default calendar when a birthdate is found.
If the contacts folder is in a user's mailbox, I recommend using the macro found at Adding Birthdays and Anniversaries to Outlook's Calendar. The macro updates the birthday field and Outlook creates the birthday and anniversary events automatically. These events are linked to the Contact; if you delete the contact or change the dates, the calendar event is deleted or updated.
The macro on this page creates an all-day event on the contact's birthday. Unlike birthday events Outlook creates automatically, the contacts are not linked to the calendar event; deleting or editing the dates will not change the event on the calendar.
To use this macro, add it to the VB Editor then select a contacts folder and run it. If there is a date in the birthday field, an all day recurring event is created for that date and a reminder is set for 12 hours before (noon the previous day).
The event is configured for 25 yearly occurrences, beginning on 1/1/2014. If the pattern start date isn't set, it would begin with the year in the birthday field and cover the next 25. Note: I recommend always setting a number of occurrences or an end date.
It may be helpful to use a category of "Public Contacts" so you know why the birthdays are on the calendar.
Sub AddBirthdays() Dim fContacts As Outlook.folder Dim oContact As ContactItem Dim cAppt As AppointmentItem Dim pattern As RecurrencePattern Set fContacts = Application.ActiveExplorer.CurrentFolder For i = fContacts.Items.count To 1 Step -1 If fContacts.Items(i).Class = 40 Then Set oContact = fContacts.Items(i) 'Checks for a date in the birthday field If Not oContact.Birthday = "1/1/4501" Then Set cAppt = Application.CreateItem(olAppointmentItem) With cAppt .subject = oContact.FullName & "'s Birthday" .Start = oContact.Birthday .AllDayEvent = True .ReminderMinutesBeforeStart = 720 ' 12 hours .ReminderSet = True .Categories = "Birthday" .Save End With ' Now set the recurrence pattern & length Set pattern = cAppt.GetRecurrencePattern With pattern .RecurrenceType = olRecursYearly ' # of occurrences from the birthdate unless a pattern start date is set .Occurrences = 25 .PatternStartDate = #1/1/2014# '.PatternEndDate = #6/1/2025# ' or set no end date '.NoEndDate = True End With cAppt.Save End If End If Next i Set fContacts = Nothing End Sub
How to use macros
First: You will need macro security set to low during testing.
To check your macro security in Outlook 2010 or 2013, go to File, Options, Trust Center and open Trust Center Settings, and change the Macro Settings. In Outlook 2007 and older, it’s at Tools, Macro Security.
After you test the macro and see that it works, you can either leave macro security set to low or sign the macro.
Open the VBA Editor by pressing Alt+F11 on your keyboard.
To put the code in a module:
- Right click on Project1 and choose Insert > Module
- Copy and paste the macro into the new module.
More information as well as screenshots are at How to use the VBA Editor