Using VBA to Change Business Card Image & Layout

Last reviewed on December 30, 2013

Code Sample 2: Change the business card image on all contacts in a folder

This variation of the code changes all of the business card images in the default contacts folder. You can use an If... then statement (sample below) to restrict the changes to a contacts matching a specific condition.

As with the earlier code, although we limit this sample code to changing the business card image, you can use change any contact field by editing the field name.

Public Sub ChangeBusinessCardImage()
Dim obj As Object
Dim oFolder As Outlook.MAPIFolder
Dim oContact As Outlook.ContactItem
Dim colItems As Outlook.Items
Dim i As Long
Dim lCount As Long

Set oFolder = Application.Session.GetDefaultFolder(olFolderContacts)
Set colItems = oFolder.Items

lCount = colItems.Count
For i = 1 To lCount
Set obj = colItems.Item(i)
If (obj.Class = olContact) Then
Set oContact = obj

oContact.AddBusinessCardLogoPicture ("c:\image\logo.png")
oContact.Save

End If
Next
End Sub

Change Contacts based on property values

By adding a simple If... Then statement around the code the changes the picture, you can run it on all contacts in the folder but apply it only to certain contacts, unlike Code Sample 1, which works on selected contacts.

See Change the image on a Business Card based on the Category for VBA code that changes the business card image based on the category a contact is assigned to.

 If oContact.Sensitivity = olPrivate Then
    oContact.AddBusinessCardLogoPicture ("c:\image\logo.png")
    oContact.Save
 End If

To add a company logo to all contacts from a specific company, the code will look like this:

 If oContact.CompanyName = "CDOLive" Then
     oContact.AddBusinessCardLogoPicture ("C:\image\logo.gif")
     oContact.Save
 End If

Note that this code is case sensitive. Before using it, you should use a group by Company view and verify you are using only variation of a company name. If more than one exist, drag the contacts to one group.

Code Sample 3: Change the business card layout to match the selected contact

Written by

Diane Poremsky
A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

If the Post Coment button disappears, press your Tab key.