Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in
x
or
x
x
Register
x

or

How to calculate and show ages by birthdays on Outlook calendar?

Generally speaking, a contact’s birthday will be automatically added as a yearly recurring appointment in the calendar. But do you know how to calculate the contact’s age and show the age directly in the calendar view? This article will introduce a VBA to figure out each contact’s age and show the age on the subject of relative recurring appointment in Outlook.

Calculate and show ages by birthdays on Outlook calendar

Office Tab - Enable Tabbed Editing and Browsing in Office, and Make Work Much Easier...
Kutools for Outlook - Brings 100 Powerful Advanced Features to Microsoft Outlook
  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by rules; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails at once; Auto Add Greeting when reply; Auto Add Date&Time into subject...
  • Attachment Tools: Auto Detach, Compress All, Rename All, Auto Save All... Quick Report, Count Selected Mails, Remove Duplicate Mails and Contacts...
  • More than 100 advanced features will solve most of your problems in Outlook 2010-2019 and 365. Full features 60-day free trial.

arrow blue right bubbleCalculate and show ages by birthdays on Outlook calendar

To calculate each contact’s age and show the age in the subject of relative recurring appointment in Outlook calendar, please do as follows:

1. Open the default calendar folder, and press Alt + F11 keys to open the Microsoft Visual Basic for Applications window.

2. Click Insert > Module, and then paste below VBA code into the new module window.

VBA: Calculate and show contacts’ ages in Outlook calendar

Option Explicit
Public Sub UpdateAges()
Dim xOlApp As Outlook.Application
Dim xOlFolder As Outlook.Folder
Dim xOlItems As Outlook.Items
Dim xAppointmentItem As AppointmentItem
Dim xAge As Integer
Dim xOlProp As Outlook.UserProperty
Set xOlApp = Outlook.Application
Set xOlFolder = Session.GetDefaultFolder(olFolderCalendar)
Set xOlItems = xOlFolder.Items
For Each xAppointmentItem In xOlItems
If (InStr(1, xAppointmentItem.Subject, "Birthday") Or InStr(1, xAppointmentItem.Subject, "Anniversary")) And xAppointmentItem.IsRecurring = True Then
With xAppointmentItem
If xAppointmentItem.UserProperties("Original Subject") Is Nothing Then
Set xOlProp = xAppointmentItem.UserProperties.Add("Original Subject", olText, True)
xOlProp.Value = .Subject
.Save
End If
xAge = DateDiff("yyyy", .Start, Date)
.Subject = .UserProperties("Original Subject") & " (" & xAge & " in " & Format(Date, "yyyy") & ")"
.Save
End With
End If
Next
Set xAppointmentItem = Nothing
Set xOlItems = Nothing
Set xOlFolder = Nothing
Set xOlApp = Nothing
End Sub

3. Press the F5 key or the Run button to run this VBA.

When you return to the default calendar, you will see each contact’s age is figured out and shown in the subject of the recurring birthday appointment. See screenshot:

Notes:
(1) In the subject of a certain contact’s recurring birthday appointment, this contact’s age is embraced by parentheses similar as (41 in 2017), 41 is the age, and 2017 is the current year.
(2) If you change a certain contact’s birthday in contact folder, the age will be removed from the calendar automatically.
(3) This VBA work with the default Outlook calendar only.


arrow blue right bubbleRelated Articles


Kutools for Outlook - Brings 100 Advanced Features to Outlook, and Make Work Much Easier!

  • Auto CC/BCC by rules when sending email; Auto Forward Multiple Emails by custom; Auto Reply without exchange server, and more automatic features...
  • BCC Warning - show message when you try to reply all if your mail address is in the BCC list; Remind When Missing Attachments, and more remind features...
  • Reply (All) With All Attachments in the mail conversation; Reply Many Emails in seconds; Auto Add Greeting when reply; Add Date into subject...
  • Attachment Tools: Manage All Attachments in All Mails, Auto Detach, Compress All, Rename All, Save All... Quick Report, Count Selected Mails...
  • Powerful Junk Emails by custom; Remove Duplicate Mails and Contacts... Enable you to do smarter, faster and better in Outlook.
shot kutools outlook kutools tab 1180x121
shot kutools outlook kutools plus tab 1180x121
 
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.