ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   saving in other File types (https://www.excelbanter.com/excel-programming/354212-saving-other-file-types.html)

Jason

saving in other File types
 
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

John Keith[_2_]

saving in other File types
 
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
--
Regards,
John


"Jason" wrote:

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


Cher

saving in other File types
 
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

"Jason" wrote:

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



All times are GMT +1. The time now is 07:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com