My Tech Scrap


Friday, 18 June 2010

How to Import multiple .vCard files in Outlook ?

This can also be done using a VBA macro. First create a folder on the root of the C: drive and name it VCARDS. Next copy all your individual vCard files (.vcf) to this newly created folder. Next open Outlook and click ALT + F11 to open the VBA editor. 

Click TOOLS --> REFERENCES and then select Microsoft Scripting Runtime andWindows Script Host Object Model from the list and place checks in the box next to each and click OK. 

Next click INSERT --> MODULE and copy and paste the code below into the blank module. Save and run the macro to automatically import and save all the individual files into Outlook.

Sub OpenSaveVCard()
Dim objWSHShell As IWshRuntimeLibrary.IWshShell
Dim objOL As Outlook.Application
Dim colInsp As Outlook.Inspectors
Dim strVCName As String
Dim fso As Scripting.FileSystemObject
Dim fsDir As Scripting.Folder
Dim fsFile As Scripting.File
Dim vCounter As Integer
Set fso = New Scripting.FileSystemObject
Set fsDir = fso.GetFolder("C:\VCARDS")

For Each fsFile In fsDir.Files

    strVCName = "C:\VCARDS\" & fsFile.Name
    Set objOL = CreateObject("Outlook.Application")
    Set colInsp = objOL.Inspectors
        If colInsp.Count = 0 Then
        Set objWSHShell = CreateObject("WScript.Shell")
        objWSHShell.Run Chr(34) & strVCName & Chr(34)
        Set colInsp = objOL.Inspectors
    If Err = 0 Then
            Do Until colInsp.Count = 1
            colInsp.Item(1).Close olDiscard
            Set colInsp = Nothing
            Set objOL = Nothing
            Set objWSHShell = Nothing
        End If
    End If


End Sub
Referance >>

1 comment:

  1. My sister like walking around the Inet and once she caught a virus. My data was lost I could restore almost all data except MS Outlook emails. To my good fortune a friend offered me a nice utility for resolving problem and it was effective and might be curious for using in this issue - recover .pst.