Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9
Default Fixed Length, Text Formatted

Hello,

We send data to another company as a comma separated txt file. Now I am
being told to switch to the fixed length format (*.txt) instead of the comma
separated format (*.csv).

I am not sure how to go about this. Any suggestions are greatly welcomed.

I am starting with a plain excel export from access. And, I have been given
fixed character lengths to apply. Other postings here suggest using the
Courier New font (which is fixed-width - all characters), then setting the
column widths for the character count in each column. Then use Save As with
the prn file type.

How do you set the character count? Do you use Conditional Formatting or
Data Validation? And if so how can you tell if this has been applied?

Then how do you convert the prn file to *txt?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,441
Default Fixed Length, Text Formatted

Try the macro below. All values as shown in the activesheet will be padded to 25 characters wide,
so that everything will line up nicely.

HTH,
Bernie
MS Excel MVP

Sub ExportTo25WidthColumnsPRN()

Dim FName As String
Dim WholeLine As String
Dim FNum As Integer
Dim RowNdx As Long
Dim ColNdx As Integer
Dim StartRow As Long
Dim EndRow As Long
Dim StartCol As Integer
Dim EndCol As Integer
Dim myW As Integer

myW = 25


FName = Application.GetSaveAsFilename( _
Left(ActiveWorkbook.FullName, Len(ActiveWorkbook.FullName) - 4) & ".prn")

Application.ScreenUpdating = False
On Error GoTo EndMacro:
FNum = FreeFile

With Intersect(ActiveSheet.UsedRange, Rows("1:65536"))
StartRow = .Cells(1).Row
StartCol = .Cells(1).Column
EndRow = .Cells(.Cells.Count).Row
EndCol = .Cells(.Cells.Count).Column
End With

Open FName For Output Access Write As #FNum

For RowNdx = StartRow To EndRow
WholeLine = ""
For ColNdx = StartCol To EndCol
WholeLine = WholeLine & Left(Cells(RowNdx, ColNdx).Text & _
Space(myW), myW)
Next ColNdx
Print #FNum, WholeLine

Next RowNdx

EndMacro:
On Error GoTo 0
Application.ScreenUpdating = True
Close #FNum
End Sub

"Novice2000" wrote in message
...
Hello,

We send data to another company as a comma separated txt file. Now I am
being told to switch to the fixed length format (*.txt) instead of the comma
separated format (*.csv).

I am not sure how to go about this. Any suggestions are greatly welcomed.

I am starting with a plain excel export from access. And, I have been given
fixed character lengths to apply. Other postings here suggest using the
Courier New font (which is fixed-width - all characters), then setting the
column widths for the character count in each column. Then use Save As with
the prn file type.

How do you set the character count? Do you use Conditional Formatting or
Data Validation? And if so how can you tell if this has been applied?

Then how do you convert the prn file to *txt?



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default Fixed Length, Text Formatted

To answer your last question, prn is text, so just rename from prn to txt.
--
David Biddulph

"Novice2000" wrote in message
...
Hello,

We send data to another company as a comma separated txt file. Now I am
being told to switch to the fixed length format (*.txt) instead of the
comma
separated format (*.csv).

I am not sure how to go about this. Any suggestions are greatly welcomed.

I am starting with a plain excel export from access. And, I have been
given
fixed character lengths to apply. Other postings here suggest using the
Courier New font (which is fixed-width - all characters), then setting the
column widths for the character count in each column. Then use Save As
with
the prn file type.

How do you set the character count? Do you use Conditional Formatting or
Data Validation? And if so how can you tell if this has been applied?

Then how do you convert the prn file to *txt?



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
parsing data with no set delimiter or fixed length. ORLANDO V[_2_] Excel Discussion (Misc queries) 13 February 5th 08 05:06 PM
fixed length file Steve S[_2_] Excel Discussion (Misc queries) 2 March 13th 07 04:12 PM
Fixed length text file Eric Excel Discussion (Misc queries) 1 July 12th 06 10:02 PM
Advanced export/ Fixed length fields raws New Users to Excel 2 January 12th 06 02:38 PM
Create fields in a form with a fixed length sgeels Excel Discussion (Misc queries) 1 November 12th 05 05:11 AM


All times are GMT +1. The time now is 11:10 PM.

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

About Us

"It's about Microsoft Excel"