Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Flat File formating with Print# Statement
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Flat File formating with Print# Statement
You would need to open the file as a binary file to do that, have a look in
help for details. -- Michael Hopwood "Mike Field" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
import flat file | Excel Worksheet Functions | |||
how do I convert an excel file to a flat text file | Excel Discussion (Misc queries) | |||
Convert excel file to flat text file | Excel Discussion (Misc queries) | |||
Convert excel file to flat text file | Excel Discussion (Misc queries) | |||
Flat File | Excel Discussion (Misc queries) |