从 excel 导出到 txt 时如何删除 2 个双引号

How to remove 2 double quote when export from excel to txt

我正在尝试使用 vba 将 excel 列导出到 txt。 但是每个文本中都有一些额外的双引号。 如何去掉多余的双引号?

Dim field As String
Dim table As String
Dim t As Integer
Dim f As Integer
Dim lastrow As Integer
Dim myFile As String
Dim xStr As String

myFile = "D:\table.txt"

With Sheets("Sheet1")
Open myFile For Output As #1
table = """name"": """ & .Range("I2") & """," & Chr(10)
Write #1, table

lastrow = Range("A" & Rows.Count).End(xlUp).Row

For f = 2 To lastrow
    field = """names"": [" & Chr(10) & """" & .Range("B" & f) & """" & Chr(10) & _
             "],"
'Display 3 Lines of Text in a Messagebox
  Write #1, field
'    Cells(i, 1).Value = 100
Next f

Close #1
End With

我期待输出 "name": "customer",

但输出是: """name"": ""customer"",

使用 Print 而不是 Write(添加 "