bunu daha önce yapmıştık ama bir daha tekrar edelim.
Butondaki kod aşağıdaki kod ile değiştirilmiştir.
Dim objStream
Dim VcardAdi, FileName, File, encode As String
Dim rst As DAO.Recordset
Dim image_bin() As Byte
Dim GSayi As Integer
VcardAdi = Format(Date, "ddmmyyyy") & "TumKayitlar.vcf"
FileName = CurrentProject.path & "\" & VcardAdi
Set objStream = CreateObject("ADODB.Stream")
objStream.Charset = "utf-8"
objStream.Open
Dim sOrGu As String
sOrGu = "SELECT tbl_kisiler.kisi_id, tbl_kisiler.adisoyadi, tbl_kisiler.ikinciadi, tbl_kisiler.soyadi, tbl_kisiler.sirketbilgisi, tbl_kisiler.unvani, tbl_kisiler.isunvani, tbl_kisiler.dogumtarihi, tbl_kisiler.evadresi, tbl_kisiler.evtamadres, tbl_kisiler.yer_tanimlama, tbl_kisiler.evsehir, tbl_kisiler.evbolge, tbl_kisiler.evpostakodu, tbl_kisiler.evulke, tbl_kisiler.isadresi, tbl_kisiler.issehir, tbl_kisiler.isbolge, tbl_kisiler.ispostakodu, tbl_kisiler.isulke, tbl_kisiler.evtelefonu, tbl_kisiler.Notlar, tbl_kisiler.istelefonu, tbl_kisiler.websayfasi, tbl_kisiler.ceptelefonu, tbl_kisiler.ceptelefonuiki, tbl_kisiler.ceptelesi, tbl_kisiler.telfarkli, tbl_kisiler.fax, tbl_kisiler.fotograf, tbl_kisiler.epostaadresi, tbl_kisiler.secenek " & _
"FROM tbl_kisiler " & _
"WHERE tbl_kisiler.secenek='" & Form_frm_personelbilgiformu.secenek & "'"
Set rst = CurrentDb.OpenRecordset(sOrGu)
rst.MoveFirst
Me.etk_ilerle.Visible = True
GSayi = 0
Do Until rst.EOF
If rst!secenek = Me.secenek Then
objStream.WriteText "BEGIN:VCARD" & vbCrLf
objStream.WriteText "VERSION:4.0" & vbCrLf
objStream.WriteText "N:" & rst!soyadi & ";" & rst!adisoyadi & ";" & rst!ikinciadi & ";" & rst!unvani & vbCrLf
objStream.WriteText "FN:" & rst!adisoyadi & " " & rst!soyadi & vbCrLf
objStream.WriteText "ORG:" & rst!sirketbilgisi & vbCrLf
objStream.WriteText "TITLE:" & rst!isunvani & vbCrLf
File = CurrentProject.path & "\resimler\" & rst!fotograf
If FileExists(File) = True Then
Open File For Binary Access Read As #1
ReDim image_bin(LOF(1) - 1)
Get #1, , image_bin
Close #1
encode = Replace(EncodeBase64(image_bin), vbLf, vbCrLf & Space(1))
objStream.WriteText "PHOTO;TYPE=JPEG;ENCODING=B:" & encode & vbCrLf
End If
objStream.WriteText "TEL;WORK;VOICE:" & rst!istelefonu & vbCrLf
objStream.WriteText "TEL;HOME;VOICE:" & rst!evtelefonu & vbCrLf
objStream.WriteText "TEL;CELL;VOICE:" & rst!ceptelefonu & vbCrLf
objStream.WriteText "ADR;WORK:" & rst!isadresi & ";" & rst!issehir & ";" & rst!ispostakodu & ";" & rst!isulke & vbCrLf
objStream.WriteText "ADR;HOME:" & rst!evadresi & ";" & rst!evsehir & ";" & rst!evpostakodu & ";" & rst!evulke & vbCrLf
objStream.WriteText "X-MS-OL-DEFAULT-POSTAL-ADDRESS:1" & vbCrLf
objStream.WriteText "EMAIL;PREF;INTERNET:" & rst!epostaadresi & vbCrLf
objStream.WriteText "URL;WORK:" & rst!websayfasi & vbCrLf
objStream.WriteText "NOTE:" & rst!Notlar & vbCrLf
objStream.WriteText "BDAY:" & Format(rst!dogumtarihi, "yyyy-mm-dd") & vbCrLf
objStream.WriteText "REV:" & Format(Date, "yyyymmdd") & "T" & Format(Now(), "hhnnss") & "Z" & vbCrLf
objStream.WriteText "CATEGORIES:" & rst!secenek & vbCrLf
objStream.WriteText "END:VCARD" & vbCrLf
Me.etk_ilerle.Caption = rst!adisoyadi & " " & rst!soyadi
GSayi = GSayi + 1
End If
rst.MoveNext
Pause 0.5
Loop
Me.etk_ilerle.Visible = False
objStream.SaveToFile FileName, 2
Me.etk_ilerle.Visible = False
MsgBox (GSayi & " adet veri " & VcardAdi & " isimli dosyaya kaydedildi")
rst.Close
objStream.Close