PDA

View Full Version : Open up csv files and save as excel files macro



obriensj
12-19-2007, 03:45 AM
Hi,

Am a bit new to all this so any help much appreciated!

I need to design a macro that will open up numerous csv files stored on a server and save these as excel files overwriting the excel files already stored in a different path name on the server.

For example I may have 20 different csv files called:
cpcfibxgp181207a.csv (sample path name: J\shs\test\
cpcfidtrb181207a.csv (sample path name: J\shs\test\

and so on?what I need to do is save these files in this folder: J\upload\daily\
However in this folder there are already xls files here so what I need to do is take the csv file and parse the file name to bring in for example IBXGP from csv file: cpcfibxgp181207a.csv and save the file as IBXGP.xls overwriting the previous file from yesterday. Can this be done?

I think this is complicated by the fact that there are numerous csv files stored and knowing which one to pick up, for example:

cpcfibxgp181207a.csv
cpcfibxgp171207a.csv
cpcfibxgp161207a.csv

These are the last three days files and I need to be able to pick up the latest file, cpcfibxgp181207a.csv and save as IBXGP.xls overwriting the previous file in folder J\upload\daily\

Was thinking of starting with GetOpenfileName method but don?t think will work, any ideas anyone?

Thanks

Steve

figment
12-20-2007, 03:43 PM
your using consistant naming conventions so this is posible, to do this project will require a list of what CSV file names your using, and what excel name the ruslting file gets saved as.

obriensj
12-27-2007, 02:30 AM
Thanks Figment.
But how do i start writing code for this, this is where i am stuck!

Steve