Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Read text file
Hi,
I'm reading a text file originating from Unix using the Line Input #Filenumber statement. This goes haywire due to the fact that each line in the file is terminated with Chr(10), i.e. linefeed, only. Excel then reads the whole file into one string as Chr(13) is missing. Anybody know how to deal with this? Any help appreciated. jacob |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Read text file
You could do something as below using the Input Funciton (not to be confused
with the Input Statement) to read the characters individually and when you get to a LineFeed, tack on a Carriage Return before it. This procedure replaces the old file with a new one that has the Carriage Returns inserted. Sub Tester02() Open sFile For Input As #1 Do While Not EOF(1) sChar = Input(1, #1) If sChar = vbLf Then sChar = vbCr & sChar sString = sString & sChar Loop Close #1 Open sFile For Output As #1 Print #1, sString Close #1 End Sub HTH, Shockley "jacob" wrote in message ... Hi, I'm reading a text file originating from Unix using the Line Input #Filenumber statement. This goes haywire due to the fact that each line in the file is terminated with Chr(10), i.e. linefeed, only. Excel then reads the whole file into one string as Chr(13) is missing. Anybody know how to deal with this? Any help appreciated. jacob |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Read text file
Hi,
Thx, this should work. -----Original Message----- You could do something as below using the Input Funciton (not to be confused with the Input Statement) to read the characters individually and when you get to a LineFeed, tack on a Carriage Return before it. This procedure replaces the old file with a new one that has the Carriage Returns inserted. Sub Tester02() Open sFile For Input As #1 Do While Not EOF(1) sChar = Input(1, #1) If sChar = vbLf Then sChar = vbCr & sChar sString = sString & sChar Loop Close #1 Open sFile For Output As #1 Print #1, sString Close #1 End Sub HTH, Shockley "jacob" wrote in message ... Hi, I'm reading a text file originating from Unix using the Line Input #Filenumber statement. This goes haywire due to the fact that each line in the file is terminated with Chr(10), i.e. linefeed, only. Excel then reads the whole file into one string as Chr(13) is missing. Anybody know how to deal with this? Any help appreciated. jacob . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
How to read all lines from a text file into cells C10:Cxxx ? | Excel Discussion (Misc queries) | |||
Data from exported file read as text, when edited becomes a # (pic | Excel Discussion (Misc queries) | |||
to read text tablimited file | Excel Discussion (Misc queries) | |||
How do you save an excel file to be read as IBM-type text file ? | Excel Worksheet Functions | |||
Read Text File into Excel Using VBA | Excel Discussion (Misc queries) |