View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
thoc01 thoc01 is offline
external usenet poster
 
Posts: 1
Default End-of-line markers in tab delimited text file

We have some VBA code in Excel which loads a tab delimited text file into a new sheet using Workbooks.OpenText and then processes it row by row to perform some calculations. Data in the file is in separate sections, each with different formats and the end of each section is marked with a blank line e.g.:

Section 1
Date Amount Description
01-Jul-2004 1 Test desc 1
02-Jul-2004 2 Test desc 2

Section 2
Counter Amount Date Description
1 3 01-Jul-2004 Test desc 3
2 4 02-Jul-2004 Test desc 4

This was working perfectly up until the installation of Office 2003, when errors began. I have traced the problem to the end-of-line markers. The incoming text file uses a '0A' character to indicate the end of each line instead of the more usual '0D0A'. This seems to work fine for most lines, but blank lines are ignored. This results in the section changes being missed and so the code expects data in Section 2 to be in the same format as Section1 and fails.

The behaviour can be replicated by opening the file manually from the File menu and going through the text import wizard, this too loses the blank lines (regardless of the File Origin setting). Strangely though, if you right-click on the file in Explorer and choose to open it with Excel, the blank lines are retained.

Are there any settings I am missing that will allow the text import to recognise the blank lines marked by '0A'?