vba 将两个引号替换为一个/生成txt文件

vba replacing two quotation marks with one / generating txt files

我创建了一个宏,它使用 excel 中每一行的数据生成 txt 文件。我对 "(引号)

有疑问

VBA 中的一行有问题:

wsTemp.Cells(6, 1).Value = "The ""Number"" is " & wsSource.Cells(r, 3).Value

我需要这个:The "Number" is MYNUMBER

而不是我得到这个:" The ""Number"" is" MYNUMBER

这也不行:

wsTemp.Cells(6, 1).Value = "The" & Chr(34) & "Number"" is " & Chr(34) & wsSource.Cells(r, 3).Val(得到相同的输出)

我尝试用 Chr(34) 替换 ""(没用)

最后我也尝试了replace函数:

wsTemp.Cells(6, 1).Value = Replace(wsTemp.Cells(6, 1).Value, """", """)(没用)和 wsTemp.Cells(6, 1).Value = Replace(wsTemp.Cells(6, 1).Value, """", Chr(34))(效果不佳)

Replace() 确实适用于其他 Chr()Replace(wsTemp.Cells(6, 1).Value, """", "") 但不适用于 Chr(34)

无论如何,我需要一个 ",而不是两个 ' 或其他任何东西

我将生成的文件保存为 xlCurrentPlatformText 和 .txt,我也尝试过其他格式

此外,当我手动将 excel 中的相同文本保存为 txt

时,我注意到了这一点

我几乎尝试了所有方法,但没有任何效果

我使用的是 Win 7 和 Excel 2013

尝试将其作为其中之一,

With wsTemp.Cells(6, 1)
    .Value = Format(wsSource.Cells(r, 3).Value2, "\T\h\e \""\N\u\m\b\e\r\"" \i\s 0")
    .Offset(1, 0) = "The ""Number"" is " & wsSource.Cells(r, 3).Value2
    .Offset(2, 0) = "The " & Chr(34) & "Number" & Chr(34) & " is " & wsSource.Cells(r, 3).Value2
End With

所以我按照@xidgel suddgested 的方式使用 FindAndReplaceText(放屁)

我把所有的"换成了$$$$

我创建了一个文件replace.bat

fart -r "MYLOCATION*.txt" $$$$ \"

并在vba宏的末尾添加了shell执行命令

Call Shell("C:\LOCATION\replace.bat", vbNormalFocus)