saving in other File types

G

Guest

hi,

i am trying to write a code to save an excel sheet into a formatted space
delimited file type, (.PRN). i tried to save it directly using

workbooks.save(c:filename.prn), it saves it as prn but not the format that i
need, i know that its possible to specify the file type, but i would be
really thankfull if some one could help me...thanks
 
G

Guest

Are you trying to make the output file have values that are in fixed columns?

It is much better to use Excel VBA to read in the data from the cells, then
output the data directly to a .TXT file where you can use string functions to
build your output exactly the field lenghts you want, truncating any extra
characters. (On my applications I needed this to upload excel data to a
mainframe) PRN files were a mess to deal with; even when using a fixed font
and trying to keep the data cells sized properly.

Left$(vaData(lRow, 1) & Space(37), 37)
.....to create a 37 length string right padded with spaces.
then string the results of multiple strings to make up your file.

Or am I missing your point (about which format you needed)?

HTH
 
G

Guest

I needed to do the same thing. My spreadsheet was setup as a template but
you can use any format. Here is what I found to work:

If Activeworkbook.Fileformat=xltemplate then
activeworkbook.saveas "O:\Myfolder\Myfile.prn", xlCurrentPlatformText
EndIf

If you have a multi-sheet workbook this will rename the sheet you are
working with. You can always copy the specific worksheet you want to use by
using:
Sheets("Sheet3").Copy and then use the save as written above.

I hope this helps,
Cheryl
 

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