By default, Outlook doesn’t have a feature supporting you to import multiple vcards in batches. Fortunately, you can use VBA to achieve it. This article will teach you how to use VBA to bulk import all the vcards from a local disk into Outlook.
If you have a lot of contacts stored in vCard format in one of your computer local drives, so as to make use of these contacts effectively and flexibly in your Outlook, you may want to import these contacts into your Outlook. Nevertheless, you will find that Outlook only support you to import the vCard files one by one. It is OK if you just would like to import few vCards. But if you have multiple vCards to be imported, importing one by one will be a quite arduous task. Therefore, in order to import them in batches, you should resort to any extra tool, such as third party add-in or VBA codes. Here we will guide you how to use VBA to accomplish it in one go. Read on to get the detailed steps and VBA codes.
Batch Import All vCards in a Local Drive into Outlook
- At the very outset, launch your Outlook program.
- Then switch to “Developer” tab and click on “Visual Basic” button. Or you can just press “Alt + F11” key buttons.
- Next in the popup VBA editor window, you need to open a new module.
- Subsequently, copy the following VBA codes into the module window.
Sub ImportVCardsfromaLocalDrivetoOutlook() 'Change the drive letter as per your actual case Call ProcessFolders("E:\") MsgBox ("Import Successfully!") End Sub Sub ProcessFolders(sPath As String) Dim objFileSystem As Object Dim objFolder As Object Dim objFile As Object Dim objVCard As Object Dim strVCard As String Dim strFileExtension As String Dim objInspectors As Outlook.Inspectors Dim objWsShell As Object Dim objSubFolder As Object Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objFolder = objFileSystem.GetFolder(sPath) For Each objFile In objFolder.Files 'Find the vcards by file extension strFileExtension = objFileSystem.GetExtensionName(objFile) If strFileExtension = "vcf" Then Set objVCard = objFile 'Get the full path to the vCard file strVCard = objVCard.Path Set objInspectors = Outlook.Application.Inspectors If objInspectors.Count = 0 Then Set objWsShell = CreateObject("WScript.Shell") 'Open the vCard file objWsShell.Run (Chr(34) & strVCard & Chr(34)) Do Until objInspectors.Count = 1 DoEvents Loop 'Save & close the vCard to Outlook objInspectors.Item(1).CurrentItem.Save objInspectors.Item(1).Close olDiscard End If End If Next objFile 'Process all the folders and subfolders in the Disk recursively For Each objSubFolder In objFolder.SubFolders 'Skip hidden and system folders If ((objSubFolder.Attributes And 2) = 0) And ((objSubFolder.Attributes And 4) = 0) Then ProcessFolders (objSubFolder.Path) End If Next objSubFolder End Sub
- After that, you should change your Outlook macro security level to low.
- Eventually click the “Run” icon in the toolbar or press F5 key button to start the new VBA project.
- After macro finishes, you will get a message, prompting “import successfully”. Then you will find all the vCards are imported to the default Contacts folder in your Outlook.
Never Panic in the Event of Outlook Crash
If your Outlook crashes from time to time, you should raise your vigilance right now. You should make an up-to-date PST data backup. Also, if you can afford it, it is also suggested to keep a potent Outlook damage repair tool in vicinity, such as DataNumen Outlook Repair. As long as you have made the above two precautions, you will never need to panic in the event of Outlook crash.
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