I have a text file created on linux, if I open it in Word pad the file appears normally. However when I open it in notepad, and when I try to load it into excel using the code below it appears as a single line.
' Open the file
Open Filename For Input As #1
' Look for the Table Title
Do While Not (EOF(1) Or InStr(TextLine, TableTitle) > 0)
Line Input #1, TextLine
Loop
How can I split it into the original lines? Is there an end of line seperator, that vba can use?
The Function
and could be invoked by (from
immediate window
)and the output
The above example could be used to get all lines from any text file originated from any OS.
Hope this helps.
Open the linux text file using Windows "Word Pad". Save the file. Word Pad will convert the linux line-feed (\n) to carriage return+line-feed (\r\n) as it saves the file. No coding is necessary.
Linux uses a line-feed (
\n
) to denote a new line rather than the carriage return+line-feed (\r\n
) as used by Windows so you can't useLine input
, instead: