Excel to
vCard using VBA Script: Follow the simplest method to convert Excel contacts
to vCard using VB script:
- Create a new Excel sheet and fill all rows and columns according to your need.
- Now press Alt+F11 >> Copy and paste the recommended 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
- Press F5 to execute the code.
- A VCF file will be generated with the name “OutputVCF.vcf” in the path where the Excel is saved (Ex: C/ Documents and Settings/User Name / Local Settings/ Temp/ OutputVCF.VCF)
Note1: This code
is implemented only for 3 columns (First Name, Last Name and Contact Number).
If you want to add more columns then you have to modify this code.
Note2: By using VB script you will get a single .vcf file
(OutputVCF.VCF) for all your contacts. Since some of the devices (for
Ex: MS Outlook) only show the first contact from the list of all contacts after
import.SUMBER :http://excelcontacts.blogspot.co.id/
Komentar
Posting Komentar