ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Autosave of xls files in csv format with macro (https://www.excelbanter.com/excel-programming/289790-autosave-xls-files-csv-format-macro.html)

marian

Autosave of xls files in csv format with macro
 
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

Dave Peterson[_3_]

Autosave of xls files in csv format with macro
 
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



marian wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 02:54 AM.

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