I'm trying to produce a .vcf file for each line of data in an Excel file but running into runtime error 52 at the line Print #FileNum, "BEGIN:VCARD"
The spreadsheet has Latitude in col A
Longitude in Col b
Name in col C
Phone number in col D
What's causing the error?
Thanks
Geoff
The spreadsheet has Latitude in col A
Longitude in Col b
Name in col C
Phone number in col D
VBA Code:
ub Create_vcf_File()
Dim r, FileNum As Integer
Dim myfile As String
Dim mypath As String
Dim Data, LastRow As Long
Sheets("National Trust").Select
mypath = "E:\Car\Destination files\Destinations"
With ActiveSheet
LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row
End With
For r = 2 To LastRow
myfile = Cells(r, "C")
Print #FileNum, "BEGIN:VCARD"
Print #FileNum, "VERSION:3.0"
Print #FileNum, "N:" & Cells(r, "C")
Print #FileNum, "GEO" & Cells(r, "A") & Cells(r,"B")
Print #FileNum, "TEL;TYPE=WORK:" & Cells(r, "D")
Print #FileNum, "END:VCARD"
Open mypath & myfile & ".vcf" For Append As #1
Print #1, Data
Close #1
Data = ""
Next r
End Sub
What's causing the error?
Thanks
Geoff