我正在使用一个excel宏来生成一个csv文件,其中包含我作为联系人上传到gmail的所有数据。当文件上传到gmail联系人时,手机号码和工作号码会正确显示,但人员姓名会在备注框中显示为"名字:Yash"。 我附加了由宏生成的示例csv文件。
使用以下宏来生成csv' s:
Sub getcsv()
Application.ScreenUpdating = False
csvnewsheet
Dim myRange As Range
Dim NumRows As Integer
Set myRange = ActiveSheet.Range("A:A")
NumRows = Application.WorksheetFunction.CountA(myRange)
Range("E1").Select
ActiveCell.FormulaR1C1 = "First Name"
Range("E2").Select
ActiveCell.FormulaR1C1 = "=CONCATENATE(Reports!R[5]C2,"" "",Reports!R[5]C1)"
Range("E2").Select
Selection.AutoFill Destination:=Range("E2:E" & NumRows + 1)
Range("E2:E3").Select
Columns("E:E").EntireColumn.AutoFit
hide_format
Exporttocsv
DelSht
Application.ScreenUpdating = True
End Sub
Sub hide_format()
'
' hides name & place columns and then removed the formatting
'
'
Columns("A:A").Select
Selection.Delete Shift:=xlToLeft
Selection.Delete Shift:=xlToLeft
Columns("C:C").Select
Selection.Cut
Columns("A:A").Select
Selection.Insert Shift:=xlToRight
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
Selection.Borders(xlEdgeLeft).LineStyle = xlNone
Selection.Borders(xlEdgeTop).LineStyle = xlNone
Selection.Borders(xlEdgeBottom).LineStyle = xlNone
Selection.Borders(xlEdgeRight).LineStyle = xlNone
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
Sub csvnewsheet()
Dim myRange As Range
Dim NumRows As Integer
Set myRange = Worksheets("Reports").Range("A:A")
NumRows = Application.WorksheetFunction.CountA(myRange) + 3
Sheets.Add.Name = Worksheets("Reports").Range("A2").Value & "_CSV"
Worksheets("Reports").Range("A6:D" & NumRows).Copy Destination:=Worksheets(Worksheets("Reports").Range("A2").Value & "_CSV").Range("A1")
Worksheets(Worksheets("Reports").Range("A2").Value & "_CSV").Columns("A:D").AutoFit
End Sub
Sub Exporttocsv()
Dim MyPath As String
Dim MyFileName As String
MyFileName = Worksheets("Reports").Range("A2").Value & "_CSV"
If Not Right(MyFileName, 4) = ".csv" Then MyFileName = MyFileName & ".csv"
Worksheets(Worksheets("Reports").Range("A2").Value & "_CSV").Copy
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select a Folder to Save the CSV"
.AllowMultiSelect = False
.InitialFileName = "" '<~~ The start folder path for the file picker.
If .Show <> -1 Then GoTo NextCode
MyPath = .SelectedItems(1) & "\"
End With
NextCode:
With ActiveWorkbook
.saveas Filename:=MyPath & MyFileName, FileFormat:=xlCSV, CreateBackup:=False
.Close False
End With
End Sub
Sub DelSht()
Application.DisplayAlerts = False
Sheets(Worksheets("Reports").Range("A2").Value & "_CSV").Delete
Application.DisplayAlerts = True
End Sub
此宏生成包含数据的新工作表,然后执行所需的更改并另存为CSV,然后删除该工作表。
我不知道我哪里出错......但是联系人姓名不是来自gmail ...我尝试过各种其他方法,但它仍然没有用......
请帮忙!
答案 0 :(得分:1)
这是Gmail建议csv文件格式的方式。
-
这就是你的格式化方式。
您可能必须按照Gmail建议的方式对其进行格式化。