View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
tony h
 
Posts: n/a
Default Importing a .txt file issues


Just summarising the issue : you get a text version of a report which is
a good old fashined report.
The report has page breaks and page headers and footers and section
headers in it.

In this case I usually find it easiest to parse the file before
importing it. I do this using the "Open file for input" and the input
line statement. A few well planned tests (looking for blank line, the
text of the headers etc) can soon determine whether you want to keep
the line or not.

Dim TextLine As String
Open "inFILE.TXT" For Input As #1 ' Open file.
Open "outFILE.TXT" For Output As #2
Do While Not EOF(1) ' Loop until end of file.
Line Input #1, TextLine ' Read line into variable.
If Mid(TextLine, 5, 6) < "Page :" Then
Print #2, TextLine
End If
Loop
Close #1, #2

The resultant file should import with no difficulty.

If the structure is complex it may be worth parsing each line for data
and placing it directly into the spreadsheet. without seeing your text
file it is difficult to say what is best.

Good luck


--
tony h
------------------------------------------------------------------------
tony h's Profile: http://www.excelforum.com/member.php...o&userid=21074
View this thread: http://www.excelforum.com/showthread...hreadid=505339