VBOffice

Add Birthday

This macro adds the birthdays of your contacts to the calendar.

Last modified: 2018/01/22 | Accessed: 33.014  | #168
◀ Previous sample Next sample ▶
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.

If you create a new contact with a birthday, Outlook automatically adds a recurring appointment for the birthday to your calendar. If these birthdays disappear for any reason, you´d have to manually re-add all the birthdays. This macro does all the work and adds the birthdays of a to be selected contact folder to the calendar.


tip  How to add macros to Outlook
Public Sub AddBirthdays()
  Dim Folder As Outlook.MAPIFolder
  Dim Items As Outlook.Items
  Dim obj As Object
  Dim Contact As Outlook.ContactItem
  Dim BDay As Date

  Set Folder = Application.Session.PickFolder
  If Folder Is Nothing Then Exit Sub
  If Folder.DefaultItemType = olContactItem Then
  Dim i As Integer
    Set Items = Folder.Items
    For Each obj In Items
      If TypeOf obj Is Outlook.ContactItem Then
        Set Contact = obj
        BDay = Contact.Birthday
        If Year(BDay) > 0 And Year(BDay) < 4000 Then
          Contact.Birthday = 0
          Contact.Save
          Contact.Birthday = BDay
          Contact.Save
        End If
      End If
    Next
  End If
  MsgBox "done"
End Sub
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.
email  Send a message