Convert CSV to Vcard File – Download Converter App

Conversion From CSV to VCF (or vCard)

To convert a contacts from CSV to vCard file business contact format, use this easy tips.

CSV stands for Comma Separated Value with every contact field separated by comma. Your CSV file may have optional Header for the vCard fields. This format of file is easy to import into an Excel worksheet and also to export (just choose ‘Save As’ option & select CSV format).

This way data from an Excel file is transferred to a light weight file format and could also be used to upload to another systems. Now, we will see a shot intro on VCarf format and will move on to learn how to convert a CSV to vCard.

VCARD or VCF Format

In a VCARD file, we can store the contact information of a person or organization. The information contains Name, Phone numbers, Address, City, Place, Email Id etc.,

This format is accepted by Outlook, Gmail and few Email applications, Android and other Mobile Phone Operating systems etc., and the data is updated in their contacts database.

How To Convert CSV to vCard File?

The below VBA code will generate a file with Vcard 3.0 format. For example, it is assumed that the CSV file has the below fields.

FirstName, LastName, PhoneNumber

If you CSVfile has more fields, then modify the code accordingly. All possible fields of a VCARD 3.0 format is mentioned in this Wiki Link.  To execute this code, open an excel workbook, press Alt + F11, paste this code in the VB editor and press F5. This is compatible with Microsoft Office Excel Version 2003 and above.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'          Visit our website for more Tips and Tricks                      '
'                ---- Officetricks.com ----                                '
'                                                                          '
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
Private Sub Create_VCard_from_CSV()
 
    '''''CSV to vCard File Conversion code
    '''''Assign the Path of the VCF file here
    CSV_File_Path = "D:\Sample.CSV"
    VCF_File_Path = "D:\OutputVCF.VCF"
 
    '''''Open File in read mode
    iFileNum = FreeFile
    Open CSV_File_Path For Input As iFileNum
    
    '''''Open File in Write mode
    oFileNum = FreeFile
    Open VCF_File_Path For Output As oFileNum
 
    '''''Read Input File line by line till End Of File
    While Not VBA.EOF(iFileNum)
        Line Input #iFileNum, FileText
        CSVFields = VBA.Split(FileText, ",")
        
        FName = CSVFields(0)
        LName = CSVFields(1)
        PhNum = CSVFields(2)
         
        Print #oFileNum, "BEGIN:VCARD"
        Print #oFileNum, "VERSION:3.0"
        Print #oFileNum, "N:" & FName & ";" & LName & ";;;"
        Print #oFileNum, "FN:" & FName & " " & LName
        Print #oFileNum, "TEL;TYPE=CELL;TYPE=PREF:" & PhNum
        Print #oFileNum, "END:VCARD"

    Wend
    'Close the Files after the Processing
    Close #iFileNum
    Close #oFileNum
    MsgBox "Contacts Converted & Saved To: " & VCF_File_Path
    
End Sub

Both CSV and VCARD are plain File formats and they are not encrypted formats. So, both the files can be opened in a notepad or any text file editor and you will we able to interpret the data in it.

If you are familiar with these file formats and a bit of VBA code, it is easy to automate this kind of csv to vCard file conversion tasks.

Also Read: Alternate way to convert your CSV to VCF: is by uploading the CSV contacts into an Excel file and use the VBA code in this link to convert from Excel format to VCF.

Leave a Reply