Autosave of xls files in csv format with macro

M

marian

I'm having a problem to get this working:
I have an excel loaded with macros and need to save data only in csv
file with datestamp periodically. When I do my first save with code

ActiveWorkbook.SaveAs Filename:=fname, _
FileFormat:=xlCSV, CreateBackup:=False

where fname
fname = "c:\" & "mftst" & Format(Now, "yyyy-mm-dd-hh") & ".csv"
After 1st save, the whole spreadheet changes name to fname (which is
csv) and I get error from macro
How Do I keep original xls file name, and just save copy of the
spreadsheet every hour in csv?
I see that ActiveWorkbook.SaveCopyAs doesn't give option to save in
csv format

tks
marian
 
D

Dave Peterson

You can copy the activesheet to a new workbook, save that as .csv, close it and
continue what you're doing.

activesheet.copy
activeworkbook.saveas (your csv stuff here)
(activeworkbook is the newly copied worksheet's workbook)
activeworkbook.close savechanges:=false
 

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

Similar Threads


Top