Flat File formating with Print# Statement

M

Mike Field

Using Excel 2000 v9.0
I have a list of records needing to be exported to a text
file.

What I am looking for is to output all records terminated
by a CR and no LF.
Example:
AB016593AY22001816P3404RS CHR(13) AB022350AY22201022P9920
CHR(13) AB022189AY18401823502031RS CHR(13)
My list will allways be in a single column with no breaks.

The following code works, but includes Hex OD 0D 0A at the
end of each record, removing & Chr(13) from the Print
statement will still result in 0D 0A.

Sub ExportTrans()
Count = 0

Sheets("Transactions").Select

Range("A1").Select

FilePath = [AppPathName] & "FADSMant.TXT"

Close #1

On Error Resume Next

Open FilePath For Output As #1

While ActiveCell.Value <> ""

Print #1, ActiveCell.Offset(Count, 0).Value & Chr
(13)

Count = Count + 1

If ActiveCell.Offset(Count, 0).Value = "" Then
GoTo DropOut

Wend

DropOut:
Print #1, [DayToClear] & Chr(13)

Close #1

Exit Sub

Thanks,
Mike Field
 
M

Michael Hopwood

You would need to open the file as a binary file to do that, have a look in
help for details.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top