Using VBA to Change Business Card Image & Layout

Last reviewed on May 8, 2014   —  12 comments

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")

End If
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")
 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")
 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

About Diane Poremsky

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.

Please post long or more complicated questions at Outlook forums by

12 responses to “Using VBA to Change Business Card Image & Layout”

  1. Kevin Kretschmer

    Hi Diane, This works realy great, however, I've been trying modify the code of your 3rd example so that I can setup a couple of Businss Cards to use specifcally as 'Style Templates'. Ideally the macro would pull the xml from the business card from a Specific Card Name I.e. Company Name on Business Card: 'CardTemplate1'. This would allow selecting specific contatcts and applying the sytle of the template card without having to select the template itself as the first selection. Unfortunatly I don't know any VBA other than to copy and past parts of script that already work and can tweak script for specific uses. What I would like to do is:

    Set olkItem = olkFolder.Items.Find("[CompanyName] = CardTemplate1") 'to Search for CardTemplate1 and then:
    Set oModel = Application.ActiveExplorer.olkItem.Item(1) 'use the Card found as the template.

    Of course the above doesn't work and I don't know how to get it to work. Do you have any quick ways to make this work?

    1. Diane Poremsky

      Quick, no, but I will ask a dev friend. I actually meant to ask him when i wrote that article because I was trying to do something similar and gave up.

    2. Diane Poremsky

      My friend wanted to know if CardTemplate1 is a name - if so, if needs to be enclosed in single quotes.

      Set olkItem = olkFolder.Items.Find(“[CompanyName] = CardTemplate1″) ‘to Search for CardTemplate1 and then:
      Set oModel = Application.ActiveExplorer.olkItem.Item(1) ‘use the Card found as the template.

  2. Steve

    Hi Diane,

    Just wanted to say thanks for the post. It was very helpful to me for getting all of the business cards in my contact list to a uniform look. Thanks again.

  3. Scott

    Can you help me. Code 4 is exactly what I'm looking for. ButI am not sure where you put the VBA code in Outlook 2007. Are you ableto guide me please? Thanks. Scott Baker.

    1. Diane Poremsky

      I have a how to video at

      Short version: Alt+F11 to open the editor. Click on {Project1, find and double click on ThisOutlookSession and paste the code into the white pane on the right side of the editor.

    2. Brad


      Can you help me in modifying Code Sample 2? I would like the picture location to be pulled from each contact. Each contact file contains an attachment called front.jpg but I can not find the proper method to call the attachments.


    3. Diane Poremsky

      The contact picture? That should be on the card already, if there is not a business card image.

      Basically, you need to save the image then pass the url to the script. Script to save the image is here: then use the path here -
      oContact.AddBusinessCardLogoPicture ("C:\Contact Photos\" & fname)

      I'd put the two macros together in one sub (and either use itemContact or oContact throughout).

  4. Manoj

    How do I print the business card exactly as it shows up in the Business Card view?

    1. Diane Poremsky

      You can also insert it into a message and print the message form. In Outlook 201/2013, open a new message, delete you use the Insert tab > Insert business card button. It can be copied from the email message and pasted into word or other document types that accept images.

      A screenshot will also work.

  5. Siraj Hussain

    Hello, Nice post. I tried it works but if i set the layout to left. if i want to set background on fit to edge it does not work. it just copy the small amount of picture and zoom that picture to the whole card. Is there any solution ?

    1. Diane Poremsky

      You'd need to tweak the image size in an image editor before inserting it. The card is 250x150, the image will be cropped if its not that ratio.

Leave a Reply

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

This site uses XenWord.