How to Quickly Print a List of All Contacts’ Birthdays in Your Outlook

This article will introduce a quick solution to print a list of the birthdays of all contacts stored in Outlook. If you have such a requirement, you will surely find this post quite helpful.

Perhaps you’ve input the birthday information to many contacts in your Outlook. Now, if you want to quickly extract the birthday of all contacts and print them in a list, you can apply the following method. It’ll teach you to utilize Outlook VBA to realize this task within seconds. If you don’t know how to use VBA, you can refer to the article – “How to Run VBA Code in Your Outlook”.

Quickly Print a List of All Contacts' Birthdays in Your Outlook

Print a List of All Contacts’ Birthdays

  1. In the first place, launch your Outlook program.
  2. Then, access Outlook VBA editor by pressing “Alt + F11” key buttons.
  3. Subsequently, put the VBA code below into an unused module.
Sub PrintListOfContactBirthdays()
    Dim objStore As store
    Dim objFolder As Folder
    Dim strBirthdayList As String
    Dim objFileSystem As Object
    Dim strTextFile As String
    Dim objTextFile As Object
 
    strBirthdayList = ""
    For Each objStore In Application.Session.Stores
        For Each objFolder In objStore.GetRootFolder.Folders
            If objFolder.DefaultItemType = olContactItem Then
               Call ProcessFolders(objFolder, strBirthdayList)
            End If
        Next
    Next
 
    'Input the birthday list into a text file
    strTextFile = Environ("Temp") & "\Birthday List.txt"
    Set objFileSystem = CreateObject("Scripting.FileSystemObject")
    Set objTextFile = objFileSystem.CreateTextFile(strTextFile, True)
    objTextFile.WriteLine (strBirthdayList)
    objTextFile.Close
 
    'Print the text file
    Shell ("notepad.exe /p " & strTextFile)
 
    Kill strTextFile
End Sub

Sub ProcessFolders(ByVal objCurFolder As Folder, strList As String)
    Dim objItem As Object
    Dim objContact As ContactItem
    Dim strBirthdayInfo As String
    Dim objSubFolder As Folder
 
    For Each objItem In objCurFolder.Items
        If objItem.Class = olContact Then
           Set objContact = objItem
 
           On Error Resume Next
           If objContact.Birthday <> #1/1/4501# Then
              strBirthdayInfo = objContact.FullName & ": " & objContact.Birthday
 
              'Exclude duplicates
              If InStr(1, strList, strBirthdayInfo, vbTextCompare) = 0 Then
                 strList = strList & vbCr & strBirthdayInfo
              End If
           End If
       End If
    Next
 
    'Process all subfolders recursively
    If objCurFolder.Folders.Count > 0 Then
       For Each objSubFolder In objCurFolder.Folders
           Call ProcessFolders(objSubFolder, strList)
       Next
    End If
End Sub

VBA Code - Print a List of All Contacts' Birthdays

  1. Afterwards, you can run this macro.
  • First off, click into “PrintListOfContactBirthdays” subroutine.
  • Then, press “F5” key button.
  1. Finally, as the macro completes, a list of all contacts’ birthdays will be printed out, like the following screenshot:Birthday List

Fix Outlook Errors as Soon as Possible

Provided that you have utilized Outlook for decades, you may have encountered errors from time to times. So, how do you deal with them generally? Commonly, a small error can be resolved by a simple restart. Yet, assuming that the issues are serious, you can firstly resort to the inbox repair tool. If unfortunately the built-in tool also fails, you have to take aid of a more excellent and reliable external utility, such as DataNumen Outlook Repair.

Author Introduction:

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

Comments are closed.