介绍
在 Snom 话机中导出的 Tbook 通讯录由双引号和逗号分隔。如果要导入联系人到 Snom 话机中,也要包含这样的格式。

但是如果当我们使用 excel 创建了联系人,保存为 csv 格式,是没有双引号的:

所以在这里我们教大家在 Excel 中使用 VB 宏,导出带有逗号和双引号的 csv 文件。
步骤
使用 Excel 打开或者创建一个联系人文件
使用鼠标选中要导出的联系人的行和列,按下 Alt + F11 打开 VBA 编辑器

在 VBA 编辑器中点击插入 -> 模块,回生成一个新的模块:


将下列代码复制到模块中:
Sub QuoteCommaExport()
' Dimension all variables.
Dim DestFile As String
Dim FileNum As Integer
Dim ColumnCount As Integer
Dim RowCount As Integer
' Prompt user for destination file name.
DestFile = InputBox("Enter the destination filename" _
& Chr(10) & "(with complete path):", "Quote-Comma Exporter")
' Obtain next free file handle number.
FileNum = FreeFile()
' Turn error checking off.
On Error Resume Next
' Attempt to open destination file for output.
Open DestFile For Output As #FileNum
' If an error occurs report it and end.
If Err <> 0 Then
MsgBox "Cannot open filename " & DestFile
End
End If
' Turn error checking on.
On Error GoTo 0
' Loop for each row in selection.
For RowCount = 1 To Selection.Rows.Count
' Loop for each column in selection.
For ColumnCount = 1 To Selection.Columns.Count
' Write current cell's text to file with quotation marks.
Print #FileNum, """" & Selection.Cells(RowCount, _
ColumnCount).Text & """";
' Check if cell is in last column.
If ColumnCount = Selection.Columns.Count Then
' If so, then write a blank line.
Print #FileNum,
Else
' Otherwise, write a comma.
Print #FileNum, ",";
End If
' Start next iteration of ColumnCount loop.
Next ColumnCount
' Start next iteration of RowCount loop.
Next RowCount
' Close destination file.
Close #FileNum
End Sub
然后点击工具栏的运行按钮:

会要求输入文件名和路径,我们填入原来 CSV 所在的目录以及想要生成新的 CSV 文件的名称点击确定。

脚本执行后就会在输入的目录创建对应的文件,打开后就发现添加了双引号和逗号:

