Outlook: Using VBA to Add vCard Information to the Contacts Folder

The OpenSaveVCard procedure lets you programmatically add the information from a vCard file as an Outlook contact.

Sue Mosher

September 23, 2002

1 Min Read
ITPro Today logo in a gray background | ITPro Today


I have a vCard file. I want to use Visual Basic for Applications (VBA) to insert information from this file into my Contacts folder. What's the easiest way to do that?

The vCard standard is to Contacts as the iCalendar and vCalendar standards are to appointments. A vCard file is just plain text structured in a specific way to meet the vCard standard.

To programmatically add the information from a vCard file to Outlook, you don't need to know the standard or write code to parse the file's text. Instead, you can use the OpenSaveVCard procedure that Listing 1 shows. At callout A in Listing 1, notice that the code uses alice.vcf as the vCard filename. To use the OpenSaveVCard procedure, you need to replace alice.vcf with the name of your vCard file.

Before running the code, you need to use Tools, References in VBA to add a reference to the Windows Script Host (WSH) object model library (wshom.ocx). This programming library is present in Windows 98 and later. The OpenSaveVCard procedure uses the Run method of the WshShell object (also called the Shell object) to run the vCard file. You can use the Shell.Run method any time you want to run a file or program from Outlook VBA or VBScript code.

The OpenSaveVCard procedure waits for an Inspector window to open before it saves the vCard information as an Outlook contact. So, before you run the code, make sure that you don't have any individual Outlook items open.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like