ThomasLafferty
Instructor
I have written a routine in VBA for Excel XP which imports a tab delimited text file into my workbook. The original file looks like this:
When I import it to Excel, all the quotes are stripped out, so it looks like this:
The problem is that when I export it back out as text, which is a necessity, the quotes are not put back in, and they MUST be there. If I import the same file with the text qualifier set to xlSingleQuote, it leaves the quotes where they need to be, but when I save the file as a text file, the quotes are doubled, like this:
I am making modifications to the imported file in my workbook and need to be able to save it so that only single quotes appear.
I have tried using code to add the quotes directly in the sheet before saving as text, and this is successful, but the text file ends up with double quotes. Any ideas?
Born once die twice; born twice die once.
Code:
"B3" "2421835" "2421835" "TP" 05/17/07 1175.00 "CEI" 05/06/07
"N9" "IT" "KUP"
"N9" "BF" "YA"
"N9" "PO" "CA23WHSEF"
"N1" "SH" "CONOCO PHILLIPS"
"N3" "KUPARUK MATERIALS WHSE" ""
"N4" "PRUDHOE BAY" "AK" "99734" "US"
"N1" "CN" "UNITECH OF ALASKA"
"N3" "7600 KING STREET" ""
"N4" "ANCHORAGE" "AK" "99518" "US"
"N7" "KW" "5690"
"LX" 1
"LXN9" "PH" "S"
"L5" 1 "CONNEXS 20' M/T FOR REFIL" "BKHL" "N"
"L0" 1 10000 "LC" 10000 "N" 2 "PCS" "L"
"L1" 1 1000.00 "FR" 1000.00 "400" "FREIGHT CHARGE"
"L1" 2 175.00 "FR" 175.00 "405" "17.5% FUEL SURCHARGE"
"L3" 10000 "G" 1175.00
When I import it to Excel, all the quotes are stripped out, so it looks like this:
Code:
B3 2421835 2421835 TP 05/17/07 1175.00 CEI 05/06/07
N9 IT KUP
N9 BF YA
N9 PO CA23WHSEF
N1 SH CONOCO PHILLIPS
N3 KUPARUK MATERIALS WHSE
N4 PRUDHOE BAY AK 99734 US
N1 CN UNITECH OF ALASKA
N3 7600 KING STREET
N4 ANCHORAGE AK 99518 US
N7 KW 5690
LX 1
LXN9 PH S
L5 1 CONNEXS 20' M/T FOR REFIL BKHL N
L0 1 10000 LC 10000 N 2 PCS L
L1 1 1000.00 FR 1000.00 400 FREIGHT CHARGE
L1 2 175.00 FR 175.00 405 17.5% FUEL SURCHARGE
L3 10000 G 1175.00
The problem is that when I export it back out as text, which is a necessity, the quotes are not put back in, and they MUST be there. If I import the same file with the text qualifier set to xlSingleQuote, it leaves the quotes where they need to be, but when I save the file as a text file, the quotes are doubled, like this:
Code:
"""B3""" """2421835""" """2421835""" """TP""" 5/17/2007 1175 """CEI""" 5/6/2007
"""N9""" """IT""" """KUP"""
"""N9""" """BF""" """YA"""
"""N9""" """PO""" """CA23WHSEF"""
"""N1""" """SH""" """CONOCO PHILLIPS"""
"""N3""" """KUPARUK MATERIALS WHSE""" """"""
"""N4""" """PRUDHOE BAY""" """AK""" """99734""" """US"""
"""N1""" """CN""" """UNITECH OF ALASKA"""
"""N3""" """7600 KING STREET""" """"""
"""N4""" """ANCHORAGE""" """AK""" """99518""" """US"""
"""N7""" """KW""" """5690"""
"""LX""" 1
"""LXN9""" """PH""" """S"""
"""L5""" 1 """CONNEXS 20' M/T FOR REFIL""" """BKHL""" """N"""
"""L0""" 1 10000 """LC""" 10000 """N""" 2 """PCS""" """L"""
"""L1""" 1 1000 """FR""" 1000 """400""" """FREIGHT CHARGE"""
"""L1""" 2 175 """FR""" 175 """405""" """17.5% FUEL SURCHARGE"""
"""L3""" 10000 """G""" 1175
I am making modifications to the imported file in my workbook and need to be able to save it so that only single quotes appear.
I have tried using code to add the quotes directly in the sheet before saving as text, and this is successful, but the text file ends up with double quotes. Any ideas?
Born once die twice; born twice die once.