How to Hide Fax Entries in Your Outlook “Select Names” List via VBA

Perhaps you’ve discovered that your Outlook “Select Names” list contains not only the email addresses but also the fax entries. It is too chaotic. Thus, in this article, we will teach you how to quickly hide these redundant fax entries.

When you compose a mail and intend to add recipients, you may be accustomed to clicking “To” field to select recipients in the “Select Names” list. In this case, you may find that there are some fax entries being mixed up with the email addresses. It is very inconvenient for you to locate and select your desired email addresses. You must hope to hide them. So, here we will show you how to realize it.

Hide Fax Entries in Your Outlook "Select Names" List via VBA

Hide Existing Contacts’ Fax Entries in “Select Names” List

  1. At the very outset, start your Outlook application properly.
  2. Then switch to “Developer” tab and click on the “Visual Basic” button.
  3. Next you will get access to “Microsoft Visual Basic for Applications” window.
  4. Subsequently, you should open a new module.
  5. Then copy the following VBA code into this module.
Sub HideFaxNumbers_ExistingContacts()
    Dim objStores As Outlook.Stores
    Dim objStore As Outlook.Store
    Dim objPSTFile As Outlook.Folder
    Dim objFolders As Outlook.folders
    Dim objFolder As Object

    Set objStores = Outlook.Application.Session.Stores
 
    'Process all Outlook PST files in your Outlook
    For Each objStore In objStores
        Set objPSTFile = objStore.GetRootFolder
        For Each objFolder In objPSTFile.folders
            Call ProcessFolders(objFolder)
        Next
    Next
End Sub

Sub ProcessFolders(ByVal objCurrentFolder As Outlook.Folder)
    Dim objContact As Outlook.ContactItem
    Dim objSubfolder As Outlook.Folder
 
    On Error Resume Next
    If objCurrentFolder.DefaultItemType = olContactItem Then
       For Each objContact In objCurrentFolder.Items
           'Add "Fax: " prefix in fax numbers of existing contacts
           With objContact
            If .BusinessFaxNumber <> "" And InStr(.BusinessFaxNumber, "Fax:") = 0 Then
               .BusinessFaxNumber = "Fax: " & .BusinessFaxNumber
            End If
            If .HomeFaxNumber <> "" And InStr(.HomeFaxNumber, "Fax:") = 0 Then
               .HomeFaxNumber = "Fax: " & .HomeFaxNumber
            End If
            If .OtherFaxNumber <> "" And InStr(.OtherFaxNumber, "Fax:") = 0 Then
               .OtherFaxNumber = "Fax: " & .OtherFaxNumber
            End If
               .Save
           End With
      Next
    End If
 
    If objCurrentFolder.folders.count > 0 Then
       For Each objSubfolder In objCurrentFolder.folders
           Call ProcessFolders(objSubfolder)
       Next
    End If
End Sub

VBA Code - Hide Existing Contacts’ Fax Numbers in “Select Names” List

  1. Next you can click into “HideFaxNumbers_ExistingContacts” subroutine and then press F5 key button to run this new macro.
  2. Eventually, after the macro finishes running, all of your Outlook contacts’ fax numbers will be added with “Fax: “ prefix. In this way, their fax entries will be hidden in “Select Names” list.

Auto Hide New Contacts’ Fax Entries in “Select Names” List

  1. In Outlook VBA editor, open the “ThisOutlookSession” project.
  2. Then copy the VBA code below into this project window.
Public WithEvents objInspectors As Outlook.Inspectors
Public WithEvents objContact As Outlook.ContactItem

Private Sub Application_Startup()
    Set objInspectors = Outlook.Inspectors
End Sub

Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
    If Inspector.CurrentItem.Class = olContact Then
       Set objContact = Inspector.CurrentItem
    End If
End Sub

Private Sub objContact_PropertyChange(ByVal Name As String)
    'Auto Add "Fax:" prefix in fax number
    Select Case Name
           Case "BusinessFaxNumber"
                If InStr(objContact.BusinessFaxNumber, "Fax:") = 0 Then
                   objContact.BusinessFaxNumber = "Fax: " & objContact.BusinessFaxNumber
                End If
          Case "HomeFaxNumber"
               If InStr(objContact.HomeFaxNumber, "Fax:") = 0 Then
                  objContact.HomeFaxNumber = "Fax: " & objContact.HomeFaxNumber
               End If
         Case "OtherFaxNumber"
              If InStr(objContact.OtherFaxNumber, "Fax:") = 0 Then
                 objContact.OtherFaxNumber = "Fax: " & objContact.OtherFaxNumber
              End If
    End Select
End Sub

VBA Code - Auto Hide New Contacts’ Fax Numbers in “Select Names” List

  1. After that, you can restart your Outlook to activate the new VBA project.
  2. Since then, every time when you enter fax number in a contact, “Fax: “ prefix will be auto added to the number, so that it won’t show up in “Select Names” list.

Wield a Potent PST Repair Utility

Many Outlook users simply rely on the inbox repair tool to fix their PST issues. However, to be honest, corrupt Outlook PST file is highly beyond the inbuilt tool’s capacity. Therefore, you had better keep a veteran and reputable third party tool in vicinity, such as DataNumen Outlook Repair. It can fix various difficult Outlook issues like a cork.

Author Introduction:

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

Comments are closed.