Excel To VCARD


How to Export Excel Data to VCARD using vba macros?

Steps:
Steps 1: Open the Developer Window on MS Excel. (Press ALT+F11)
Step 2: Write the below vba code:

Sub exportToVCF()

     Dim filePath,fso
     filePath = "D:\MyTestFile.vcf" ''''Youll can select any valid location on your system
      
     Set fso = CreateObject("Scripting.FileSystemObject")
     Set fileStream = fso.CreateTextFile(filePath)

    intRow = 2
    strName = ThisWorkbook.Sheets("Sheet1").Range("A" & intRow).Text

    While strName <> ""

        strFname = Trim(ThisWorkbook.Sheets("Sheet1").Range("A" & intRow).Text)
        strLname = Trim(ThisWorkbook.Sheets("Sheet1").Range("B" & intRow).Text)
        strPhNum = Trim(ThisWorkbook.Sheets("Sheet1").Range("C" & intRow).Text)

        fileStream.WriteLine "BEGIN:VCARD"
        fileStream.WriteLine "VERSION:4.0"
        fileStream.WriteLine "FN:" & strFname & " " & strLname
        fileStream.WriteLine "TEL;TYPE=CELL;TYPE=PREF:" & strPhNum
        fileStream.WriteLine "END:VCARD"
        intRow = intRow + 1
        strName = ThisWorkbook.Sheets("Sheet1").Range("A" & intRow).Text

   Wend

   fileStream.Close
   If fso.FileExists(filePath) Then
      MsgBox "VCF file created Successfully?"
   End If

   End Sub


Step 3: Run the module and enjoy :)