ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to convert CSV to PRN (https://www.excelbanter.com/excel-programming/374300-macro-convert-csv-prn.html)

fugazi48

Macro to convert CSV to PRN
 
I know I am not the only one to need this so I was hoping someone could help.

The search engines keep coming up with ABC software that I don't plan on
buying and I can't find any shareware.

I have dozens of CSV files that I need converted to PRN. Does anyone have a
Macro that will do this? I wish I had a batch file to do a list of filenames
but that is asking too much. Thnks.

Tom Ogilvy

Macro to convert CSV to PRN
 
do you actually want to change them from comma delimited to fixed column?

Or do you just want to rename them to have a .prn extension?

If fixed column, would they all have the same format?

Or do you just want to load them into excel and then save them as PRN -
however they come out.

for a list of files

Sub listfiles()
Dim rw as Long, sPath as String
Dim sName as String
rw = 2
sPath = "C:\MyDirectory\MySubfolder\"
sName = dir(spath & "*.csv")
do while sName < ""
cells(rw,1) = sName
sName = dir
rw = rw + 1
Loop
End sub


--
Regards,
Tom Ogilvy



"fugazi48" wrote:

I know I am not the only one to need this so I was hoping someone could help.

The search engines keep coming up with ABC software that I don't plan on
buying and I can't find any shareware.

I have dozens of CSV files that I need converted to PRN. Does anyone have a
Macro that will do this? I wish I had a batch file to do a list of filenames
but that is asking too much. Thnks.


fugazi48

Macro to convert CSV to PRN
 
I guess I thought the way our company used PRN data files was standard. Ours
has a special header with numbers telling applications how many variables
there are, how many lines of header there is, and how many samples there are.


I didn't realize a normal PRN was just a CSV with normalized columns or
something.

Excel does put a bunch of extra commas when I tried to make my own macro. I
have to make sure that I delete any blank cells that may have had data in it
at one time to prevent the commas.

"Tom Ogilvy" wrote:

do you actually want to change them from comma delimited to fixed column?

Or do you just want to rename them to have a .prn extension?

If fixed column, would they all have the same format?

Or do you just want to load them into excel and then save them as PRN -
however they come out.

for a list of files

Sub listfiles()
Dim rw as Long, sPath as String
Dim sName as String
rw = 2
sPath = "C:\MyDirectory\MySubfolder\"
sName = dir(spath & "*.csv")
do while sName < ""
cells(rw,1) = sName
sName = dir
rw = rw + 1
Loop
End sub


--
Regards,
Tom Ogilvy



"fugazi48" wrote:

I know I am not the only one to need this so I was hoping someone could help.

The search engines keep coming up with ABC software that I don't plan on
buying and I can't find any shareware.

I have dozens of CSV files that I need converted to PRN. Does anyone have a
Macro that will do this? I wish I had a batch file to do a list of filenames
but that is asking too much. Thnks.



All times are GMT +1. The time now is 03:33 PM.

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