|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 Nsp=娜!再来# 于 2018-10-3 22:19 编辑
创造手机联系人通讯录的代码,从32位电话换到64位电脑上就无法运行了,请老师们帮忙修改一下代码,谢谢!
创造手机联系人通讯录.zip
(52.94 KB, 下载次数: 13)
- Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, ByVal lpUsedDefaultChar As Long) As Long
- Function VbStrToMultiByte(VbStr As String) As Byte()
- Dim bufSize As Long
- Dim arr() As Byte
- bufSize = WideCharToMultiByte(65001, 0&, StrPtr(VbStr), Len(VbStr), 0, 0, 0, 0)
- ReDim arr(bufSize - 1)
- WideCharToMultiByte 65001, 0&, StrPtr(VbStr), Len(VbStr), arr(0), bufSize, 0, 0
- VbStrToMultiByte = arr
- '这几行代码以及上述API所起到的作用就是 手工另存为 UTF-8格式
- End Function
- Sub toANSI() '360助手 安卓系统 ANSI格式通过手机助手导入
- Dim s As String, b() As Byte, b1() As Byte, s1 As String
- For i = 2 To 89 '从第二行开始到第六行,根据实际情况修改
- s1 = s1 & "BEGIN:VCARD" & vbCrLf & "VERSION:3.0" & vbCrLf
- s1 = s1 & "CATEGORIES:" & Cells(i, 8) & vbCrLf
- s1 = s1 & "N:" & Cells(i, 1) & vbCrLf
- s1 = s1 & "TEL;TYPE=CELL:" & Cells(i, 2) & vbCrLf
- s1 = s1 & "TEL;TYPE=CELL:" & Cells(i, 3) & vbCrLf
- s1 = s1 & "TEL;TYPE=WORK:" & Cells(i, 4) & vbCrLf
- s1 = s1 & "TEL;TYPE=HOME:" & Cells(i, 5) & vbCrLf
- s1 = s1 & "EMAIL;TYPE=PREF:" & Cells(i, 6) & vbCrLf
- s1 = s1 & "ADR;TYPE=WORK:" & Cells(i, 7) & vbCrLf
- s1 = s1 & "END:VCARD" & vbCrLf
- Next
- b1 = StrConv(s1, 128)
- s = "c:\360手机助手导入.vcf"
- If Dir(s) <> "" Then Kill s
- Open s For Binary As 1
- Put 1, , b1
- Close
- MsgBox s
- End Sub
- Sub toUTH8() '' 安卓系统 Utf-8格式,直接存在手机卡中导入
- Dim s As String, b() As Byte, b1() As Byte, s1 As String
- For i = 2 To 89 '从第二行开始到第六行,根据实际情况修改
- s1 = s1 & "BEGIN:VCARD" & vbCrLf & "VERSION:3.0" & vbCrLf
- s1 = s1 & "CATEGORIES:" & Cells(i, 8) & vbCrLf '分组信息,某些机型会忽略此项,如果重要最好用手机助手导入
- s1 = s1 & "N:" & Cells(i, 1) & vbCrLf
- s1 = s1 & "TEL;TYPE=CELL:" & Cells(i, 2) & vbCrLf
- s1 = s1 & "TEL;TYPE=CELL:" & Cells(i, 3) & vbCrLf
- s1 = s1 & "TEL;TYPE=WORK:" & Cells(i, 4) & vbCrLf
- s1 = s1 & "TEL;TYPE=HOME:" & Cells(i, 5) & vbCrLf
- s1 = s1 & "EMAIL;TYPE=PREF:" & Cells(i, 6) & vbCrLf
- s1 = s1 & "ADR;TYPE=WORK:" & Cells(i, 7) & vbCrLf
- s1 = s1 & "END:VCARD" & vbCrLf
- Next
- b1 = VbStrToMultiByte(s1) '
- '所有语句都相同,只是在这里进行格式转换 ,相当于手工另存为UTF-8格式
- s = "c:\直接存在手机卡中导入.vcf"
- If Dir(s) <> "" Then Kill s
- Open s For Binary As 1
- Put 1, , b1
- Close
- MsgBox s
- End Sub
复制代码
|
|