• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Using VBA to Change Business Card Image & Layout

Slipstick Systems

› Outlook › People › Using VBA to Change Business Card Image & Layout

Last reviewed on June 22, 2015     12 Comments

Applies to: Outlook 2007, Outlook 2010

After upgrading Outlook, the business card's on all contacts will use a bland gray image. While you can create a custom form that will apply to all new contacts, the business card on existing contacts won't be updated. This is to preserve any business cards you may have already updated. Also, if you use the default card image and add contact photos, the contact photos display on the business cards. However, when you replace the business card image, it will be used instead of any contact photo.

We have three code samples available. The VBA code sample on this page changes the business card image on selected contacts
from this:to this:
Change the business card image The default business card image

Code Sample 1 (below) works on *selected* contacts, not folders. You can select only the contacts you want to change and skip any you've already updated with logos. Code Sample 2 is similar but applies the card image to all contacts in the folder. We include a sample If... Then statement to limit the changes to contacts based on the value of the Private or Company field.

The VBA in Code Sample 3 picks up the BusinessCardLayoutXml from the selected contact and applies it to all other contacts in the folder or selection.

If the contact has a contact photo, it is not replaced. However, the new business card image will override the contact photo, as seen in these before and after screenshots. If you want to use the contact photo (when a contact has a photo) on the business cards, do not change the business card image!

Changing the business card image doesn't affect the contact photo.

Code Sample 1: Use VBA to update selected business card images

This code will change the business card image on selected contacts, as you can't change the business card image using a custom form.

This code sample replaces the current image - it does not move or re-size it. For example, if the card was previously customized with an image on the right, the code will keep the size and placement on the right. To move or re-size an image or customize the card background or text, you need to change the Business card XML.

Public Sub ChangeBusinessCardImage_SelectedContacts()
    Dim Session As Outlook.NameSpace
    Dim currentExplorer As Explorer
    Dim Selection As Selection
    Dim currentItem As Object
    Dim folder As Outlook.folder
    
    Dim obj As Object
    Dim strFirstName As String
    Dim strLastName As String
    Dim strFileAs As String

    Set currentExplorer = Application.ActiveExplorer
    Set Selection = currentExplorer.Selection

    On Error Resume Next

    For Each obj In Selection
    Set folder = currentItem.Parent
        'Test for contact and not distribution list
        If obj.Class = olContact Then
            Set objContact = obj

      With objContact
          obj.AddBusinessCardLogoPicture ("C:\image\outlook.png")
        .Save
     End With
          
        End If

        Err.Clear
    Next

    Set Session = Nothing
    Set currentExplorer = Nothing
    Set obj = Nothing
    Set Selection = Nothing
    Set currentItem = Nothing
    Set folder = Nothing
End Sub

More photo and image commands

To add a contact photo, remove the contact photo, or to reset the business card to Outlook's default, replace obj.AddBusinessCardLogoPicture ("C:\image\outlook.png") in the code sample with one of the following lines:

obj.AddPicture ("path") 'adds a contact photo
obj.RemovePicture 'removes the contact photo
obj.ResetBusinessCard ' removes all custom formatting

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

More Information

Change the Business Card layout using BusinessCardLayoutXml
Change the image on a Business Card based on the Category
Changing Outlook’s Business Card layout
Using Custom Business Cards

Using VBA to Change Business Card Image & Layout was last modified: June 22nd, 2015 by Diane Poremsky

Related Posts:

  • Change the Business Card layout using BusinessCardLayoutXml
  • Change the image on a Business Card based on the Category
  • Changing Outlook's Business Card layout
  • While you can't the business card layout used by existing contacts
    Using Custom Business Cards

About 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.

Subscribe
Notify of
12 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Siraj Hussain (@guest_181479)
January 24, 2014 1:27 am
#181479

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 ?

0
0
Reply
Diane Poremsky (@guest_181539)
Reply to  Siraj Hussain
January 27, 2014 12:19 am
#181539

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.

0
0
Reply
Manoj (@guest_179531)
September 25, 2013 7:09 pm
#179531

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

0
0
Reply
Diane Poremsky (@guest_179532)
Reply to  Manoj
September 25, 2013 8:13 pm
#179532

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.

0
0
Reply
Scott (@guest_171711)
September 20, 2012 6:28 pm
#171711

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.

0
0
Reply
Diane Poremsky (@guest_171723)
Reply to  Scott
September 20, 2012 8:16 pm
#171723

I have a how to video at https://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/

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.

0
0
Reply
Brad (@guest_178498)
Reply to  Diane Poremsky
July 30, 2013 1:48 pm
#178498

Diane,

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.

Thanks,
Brad

0
0
Reply
Diane Poremsky (@guest_178531)
Reply to  Brad
July 31, 2013 9:59 pm
#178531

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: https://www.slipstick.com/developer/code-samples/export-save-outlook-contact-photos/ 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).

0
0
Reply
Steve (@guest_93867)
April 17, 2012 8:12 am
#93867

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.

0
0
Reply
Kevin Kretschmer (@guest_85430)
April 5, 2012 10:35 am
#85430

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?
Thanks.

0
0
Reply
Diane Poremsky (@guest_85522)
Reply to  Kevin Kretschmer
April 5, 2012 2:22 pm
#85522

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.

0
0
Reply
Diane Poremsky (@guest_85544)
Reply to  Kevin Kretschmer
April 5, 2012 3:17 pm
#85544

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.

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 15

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Use Classic Outlook, not New Outlook
  • How to Remove the Primary Account from Outlook
  • Disable "Always ask before opening" Dialog
  • Adjusting Outlook's Zoom Setting in Email
  • This operation has been cancelled due to restrictions
  • Remove a password from an Outlook *.pst File
  • Reset the New Outlook Profile
  • Maximum number of Exchange accounts in an Outlook profile
  • Save Attachments to the Hard Drive
  • How to Hide or Delete Outlook's Default Folders
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
  • Classic Outlook is NOT Going Away in 2026
  • Use PowerShell to Delete Attachments
  • Remove RE:, FWD:, and Other Prefixes from Subject Line
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Classic Outlook is NOT Going Away in 2026

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Newest Code Samples

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

Use PowerShell or VBA to get Outlook folder creation date

Rename Outlook Attachments

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment