PDA

View Full Version : Solved: Trying to Remove Quotes in txt File



bconner
05-06-2010, 10:39 AM
I am using the code below to remove quotes from a text file but it bombs out on the Red Highlighted section below.... Can someone help me




Dim nLength As Long
Dim sData As String
Close #1
'Get the file length.
Open "\\addfile00\Groups\Billing\Dictionaries\Rejections.txt (file://\\addfile00\Groups\Billing\Dictionaries\Rejections.txt)" For Binary As #1
nLength = LOF(1)
Close #1
sData = Space(nLength)
Open "\\addfile00\Groups\Billing\Dictionaries\Rejections.txt (file://\\addfile00\Groups\Billing\Dictionaries\Rejections.txt)" For Binary As #1
Get 1, 1, sData
sData = Replace(sData,"""," ")
nLength = Len(sData)
sData = Replace(sData, "Press <Return> to continue, or press <F7><Q> to quit: " & vbCrLf, "")
sData = Replace(sData, "COMPLETED" & vbCrLf, "")
sData = Left(sData, Len(sData) - 2) & String(nLength - Len(sData), " ") & vbCrLf
Put 1, 1, sData
Close 1

RonMcK3
05-06-2010, 11:14 AM
bconner,

Try replacing """ with """" and I believe your code should work as you expect it to.

Cheers,

bconner
05-06-2010, 12:03 PM
Worked perfectly, thanks for the suggestion

RonMcK3
05-06-2010, 12:20 PM
You're very welcome!

P.S. If this closes the issue, please mark the thread Closed. You can do this by clicking on Thread Tools in the menu bar, above, selecting Mark Closed and clicking the Apply Actions button.

Thanks,

mdmackillop
05-06-2010, 02:13 PM
For the future, consider using the ASCII value CHR(34) or a variable to represent this eg
DQ = CHR(34)
It can make you code more comprehensible than multiple """"" type strings.