How to Auto Remove Related Birthday & Anniversary When Deleting an Outlook Contact

By default, when you delete a contact, Outlook won’t auto remove its corresponding birthday and anniversary. Thus, this article will teach you to create such a function.

When you add birthday or anniversary details to a contact, Outlook will auto create related recurring birthday or anniversary events in your calendar folder. But, when you delete a contact, Outlook will not auto remove these events. There is no doubt that they are redundant. Keeping them will definitely clutter up your calendar. Why don’t you let Outlook auto remove them? Here we will guide you how to achieve it.

Auto Remove Related Birthday & Anniversary When Deleting an Outlook Contact

Auto Remove Related Birthday & Anniversary When Deleting a Contact

  1. In the first place, start your Outlook program as normal.
  2. Then you need to press “Alt + F11” key buttons in the Outlook main interface.
  3. Next, after accessing Outlook VBA editor window, you’d be required to insert a new module.
  4. And then copy the VBA code below into this module.
Sub AutoRemoveRelatedBirthdayAnniversaryEvents_DeleteContact()
    Dim objContact As Outlook.ContactItem
    Dim objAppointments As Outlook.Items
    Dim strFilter1, strFilter2 As String
    Dim objBirthdays As Outlook.Items
    Dim objAnniversaries As Outlook.Items
    Dim objAppointment As Outlook.AppointmentItem
 
    'Get the source contact
    Select Case Application.ActiveWindow.Class
           Case olExplorer
                Set objContact = ActiveExplorer.Selection.Item(1)
           Case olInspector
                Set objContact = ActiveInspector.CurrentItem
    End Select
 
    Set objAppointments = Application.Session.GetDefaultFolder(olFolderCalendar).Items
    objAppointments.IncludeRecurrences = True
 
    'Get the birthday events
    strFilter1 = "[Subject] = " & objContact.FullName & "'s Birthday"
    Set objBirthdays = objAppointments.Restrict(strFilter1)
    'Get the anniversary events
    strFilter2 = "[Subject] = " & objContact.FullName & "'s Anniversary"
    Set objAnniversaries = objAppointments.Restrict(strFilter2)
 
    'Delete the birthday events
    For Each objAppointment In objBirthdays
        objAppointment.Delete
    Next
    'Delete the anniversary events
    For Each objAppointment In objAnniversaries
        objAppointment.Delete
    Next
 
    'Delete this contact
    objContact.Delete
End Sub

VBA Code - Auto Remove Related Birthday & Anniversary When Deleting a Contact

  1. After that, you can take the steps below to add the new macro to ribbon.
  • Firstly, go to “File” > “Options”
  • Then in “Outlook Options” window, shift to “Customize Ribbon” tab.
  • Next create a “Special Delete” under “Home (Contacts)” tab.Create a “Special Delete” under “Home (Contacts)” tab
  • After that, add the new macro to this custom group.Add the new macro to this custom group
  • Lastly, click “OK” to save the changes and exit “Outlook Options” window
  1. Finally, you can back to your Contacts pane. In the ribbon, you’ll see this new macro button, like the following screenshot:
  2. Since then, every time when you want to delete a contact, you can press the new “Special Delete” button instead of the standard “Delete”, such that the related birthday and anniversary events will be automatically removed.

Prevent Unwanted Data Corruption in Outlook

Despite boasting of various excellent capabilities, Outlook still cannot keep away from damage. At that point, provided that you have a myriad of items in Outlook, data corruption will pose serious catastrophe. Hence, you have to make adequate precautions, like making periodical backups. What’s more, a reliable repair utility is a matter of necessity, such as DataNumen Outlook Repair, which is well versed in Outlook recovery.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including recover sql and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.