Saturday, April 25, 2015

Import contacts from Windows to Android

Moving on from a windows phone, was excited to setup a new Galaxy S5. But wait, how do I export my contacts? As usual tried to consult the expert.....No, not my wife!!

First and common suggestion was to  -

1. Export contacts to excel,
2. Import to gmail and
3. Sync on new phone.

Seriously??!!...was surprised to learn that there is no easy way to export contacts from windows to android and what if someone didn't want to upload contacts to gmail and sync?

Post an hour of research; resorted to -

1. Install "Contacts Backup -- Excel & Email Support" app on Windows Phone
2. Using the app, export contacts as excel to email
3. Create VCard file using below code...Ref: convert-contacts-in-excel-to-vcf-format
4. Email VCard file and Import into new phone

Code - 

Sub Create_VCF()
    'Open a File in Specific Path in Output or Append mode
    Dim FileNum As Integer
    Dim iRow As Double
    iRow = 2
    FileNum = FreeFile
    OutFilePath = ThisWorkbook.Path & "\OutputVCF.VCF"
    Open OutFilePath For Output As FileNum
    'Loop through Excel Sheet each row and write it to VCF File
    While VBA.Trim(Sheets("Sheet1").Cells(iRow, 1)) <> ""
        FName = VBA.Trim(Sheets("Sheet1").Cells(iRow, 1))
        LName = VBA.Trim(Sheets("Sheet1").Cells(iRow, 2))
        PhNum = VBA.Trim(Sheets("Sheet1").Cells(iRow, 3))
        Print #FileNum, "BEGIN:VCARD"
        Print #FileNum, "VERSION:3.0"
        Print #FileNum, "N:" & FName & ";" & LName & ";;;"
        Print #FileNum, "FN:" & FName & " " & LName
        Print #FileNum, "TEL;TYPE=CELL;TYPE=PREF:" & PhNum
        Print #FileNum, "END:VCARD"
        iRow = iRow + 1
    Wend
    'Close the File
    Close #FileNum
    MsgBox "Contacts Converted to Saved To: " & OutFilePath
End Sub

Hopefully someone would save their precious time!

-- MA