VBOffice

Add Birthday

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

Last modified: 2018/01/22 | Accessed: 4.108  | #168
◀ Previous sample Next sample ▶
SAM SAM
Determine the "identity" of your emails. Set with SAM the sender and the folder folder for sent items with the help of rules.

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
OLKeeper OLKeeper
OLKeeper reliably prevents users from closing their Outlook window and thus possibly missing reminders or e-mails.
email  Send a message