Saving an Excel file as a CSV using a Macro

  • Thread starter Thread starter doug
  • Start date Start date
D

doug

Thanks. Tried this but this simply closes the active
worksheet without saving it. I do need to overwrite the
existing csv file each time the macro is run.

The macro I had is as follows:

Range("A1").Select
Workbooks.Open Filename:= _ "Worksheet 2.csv"
Windows("API model Worksheet 1.xls").Activate
Range("A17").Select
Selection.Copy
Windows("Worksheet 2.csv").Activate
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Range("A2").Select
Application.CutCopyMode = False
Workbooks("E9B.csv").Save
ActiveWindow.Close
Range("A1").Select

Answering Yes to the resulting pop up message(detailed
below) results in the SAVE AS box being displayed.
 
Well that happens when you don't provide enough
information.

if the instruction that is making that message (You can
check if you debug your code step by step)
is:
ActiveWindow.Close
then replace it for:
ActiveWorkbook.close false
but you previously save the file

if your problem is that some times your file already exist
on disk then you can delete it previous to the save
command with:
on error resume next
kill "E9B.csv"
Workbooks("E9B.csv").Save



Francisco Mariscal
fcomariscal at hotmail dot com
 
Just a note to say thanks.

Got it sorted, but couldn't have done it without your
input.

Regards
Doug
 
Back
Top