Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
import flat file jatman Excel Worksheet Functions 3 October 17th 08 09:20 PM
how do I convert an excel file to a flat text file Lannutslp Excel Discussion (Misc queries) 1 June 3rd 05 10:17 AM
Convert excel file to flat text file Lannutslp Excel Discussion (Misc queries) 1 June 1st 05 03:48 AM
Convert excel file to flat text file Gary's Student Excel Discussion (Misc queries) 0 June 1st 05 12:17 AM
Flat File Max Excel Discussion (Misc queries) 4 December 20th 04 03:33 PM


All times are GMT +1. The time now is 04:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"