How to Quickly Export All Members of an Outlook Contact Group to Separate vCard Files

Instead of exporting an Outlook contact group to a vCard file, some users hope to export all group members to individual vCard files. In this article, we’ll share a way to achieve it in quick time.

As we all know, it is very easy to export an Outlook contact to a vCard (.vcf) file. But there isn’t native function for users to export the members of a contact group to individual vCard files. Therefore, in the followings, we will introduce a method which uses VBA code to realize it. If you are interested in it, please read on to get its detailed steps.

Export All Members of a Contact Group to Separate vCard Files

  1. To start with, trigger Outlook VBA editor.
  2. Then, copy and paste the following code into an empty module.
Sub ExportContactGroupMembersToSeparateVCardFiles()
    Dim objContactGroup As Outlook.DistListItem
    Dim objContacts As Outlook.Items
    Dim objGroupMember As Outlook.Recipient
    Dim objShell, objWindowsFolder As Object
    Dim strFolderPath, strVCardFilePath As String
    Dim strEmailAddress, strName As String
    Dim i, n As Long
    Dim strFilter As String
    Dim objFoundContact, objTempContact As Outlook.ContactItem
 
    'Get the contact group
    Select Case TypeName(Application.ActiveWindow)
           Case "Inspector"
                Set objContactGroup = ActiveInspector.CurrentItem
           Case "Explorer"
                Set objContactGroup = ActiveExplorer.Selection.Item(1)
    End Select
 
    Set objContacts = objContactGroup.Parent.Items
 
    'Select a local folder to save the exported vcard file
    Set objShell = CreateObject("Shell.Application")
    Set objWindowsFolder = objShell.BrowseForFolder(0, "Select a Windows Folder:", 0, "")
 
    If Not objWindowsFolder Is Nothing Then
       strFolderPath = objWindowsFolder.self.Path & "\"
 
       For i = 1 To objContactGroup.MemberCount
           Set objGroupMember = objContactGroup.GetMember(i)
           strEmailAddress = objGroupMember.Address
 
           'If the member is an existing contactitem,
           'Export the contact item
           For n = 1 To 3
               strFilter = "[Email" & n & "Address] = " & strEmailAddress
               Set objFoundContact = objContacts.Find(strFilter)
               If Not objFoundContact Is Nothing Then
                  strVCardFilePath = strFolderPath & objFoundContact.FullName & ".vcf"
                  objFoundContact.SaveAs strVCardFilePath, olVCard
                  Exit For
               End If
           Next n
 
           'If the member is not an existing contactitem,
           'Create a temp contactitem for the member and export it
           If objFoundContact Is Nothing Then
              strName = Split(strEmailAddress, "@")(0)
              strName = UCase(Left(strName, 1)) & Right(strName, Len(strName) - 1)
              strVCardFilePath = strFolderPath & strName & ".vcf"

              Set objTempContact = Application.CreateItem(olContactItem)
              With objTempContact
                   .FullName = strName
                   .Email1Address = strEmailAddress
                   .SaveAs strVCardFilePath, olVCard
                   .Close olDiscard
              End With
            End If
         Next

       'Open the local folder
       Call Shell("explorer.exe " & strFolderPath, vbNormalFocus)
    End If
End Sub

VBA Code - Export All Members of a Contact Group to Separate vCard Files

  1. After that, for convenience, add this macro to Quick Access Toolbar according to the “Optional Step” in “How to Run VBA Code in Your Outlook“.
  2. Finally, follow the steps to try this macro.
  • First off, select or open a contact group.
  • Then, hit the macro button in Quick Access Toolbar.Run Macro
  • Next, in the popup dialog box, choose a local folder to save the exported vCard files.Select Windows Folder
  • After click “OK”, the macro will export the group members to vCard files.
  • When macro finishes, the local folder will open up. It contains the vCard files corresponding to the source contact group members, as shown in the image below.Export Group Members to vCard Files

Safeguard Your Outlook PST File

Although Outlook is admittedly susceptible to corruption, you can make effective precautions to safeguard your Outlook PST data. For example, as long as you keep consistent and updated PST data backups, you can be immune from PST data loss. And if there is not valid recent backup, you still can resort to a powerful external fix tool, such as DataNumen Outlook Repair. It can repair Outlook file in a jiffy.

Author Introduction:

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

Comments are closed.