vba用一个/生成txt文件replace两个引号
我已经创build了一个macros,该macros使用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""
(没有工作)
我也试过在最后换掉function:
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(放屁)
我把所有"
换成了$$$$
我创build了一个文件replace.bat
fart -r "MYLOCATION*.txt" $$$$ \"
并在vbamacros的末尾添加了shell执行命令
Call Shell("C:\LOCATION\replace.bat", vbNormalFocus)