View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default saveas fixed text for unix

select all you cells and set the font as courier new (a mono spaced font).
the autofit your columns or manually adjust the width.

Then do file=Save as and select Formatted Text (space delimited) (.prn)

to be more exact, you might go to a second sheet and put in formula in A1
like

=Sheet1!A1 & rept(" ",20-len(Sheet1!A1))



then dragfill down and across to capture your data.

Adjust the formula if you want to left pad the value.

then select all the cells and do Edit=copy, then Edit=Paste Special and
select values. This replaces the formulas.

then you can copy the sheet to a new workbook and save as above after
autofitting the columns.

An alternative is to use low level file io to write out the file a cell at a
time/a line at a time using space padding as above. Unix uses vblf as a
line terminator I believe, while windows uses vbcrlf. I assume Unix will be
able to handle the file, but if not, you will have to use code to terminate
with vblf.

--
Regards,
Tom Ogilvy

"jeffP" wrote in message
...
Hi all,
I've got a project that takes a *dbf file into Excel, does some clean up
etc, then I need to save it as a fixed length text file that's able to be
imported into a Unix system. I've got most of it done but now I can't get

it
exported or saved into a fixed field length text file.I've worked w/ comma
delimited files but this has me lost.
I have 8 columns that need to be set w/ fixed character lengths even

though
they hold varying length data. Then I need to export/save the sheet as a
text file for the Unix people.
As I mentioned , I'm really lost / stuck and any help is , as always,
greatly appreciated.

--
jeff