0

I would like to export a number of excel files to .csv using a macro that specifies the column separator.

I've read that the way to get excel to export with a custom separator eg. "|" instead of "," is to change the separator in the Regional Settings in your control panel.

I did this and it worked fine when I export a single file, however when I try to use a macro to export using the following snippet, the file still saves with the default comma separators.

    ActiveWorkbook.SaveAs Filename:= _
    "C:\Export\newfile.csv", FileFormat _
    :=xlCSV, CreateBackup:=False

Can anyone tell me why this is happening? Is there a method to save a file through VBA that will use the separator I have specified?

pnuts
  • 58,317
  • 11
  • 87
  • 139
unusualhabit
  • 103
  • 1
  • 4
  • Consider looking at this [SO link.](http://stackoverflow.com/questions/13496686/how-to-save-semi-colon-delimited-csv-file-using-vba) – Parfait Sep 28 '14 at 16:14
  • Got it. Setting the Local parameter to True did it. Thanks. – unusualhabit Sep 28 '14 at 16:25
  • possible duplicate of [excel macro save as CSV with ; separator](http://stackoverflow.com/questions/19265636/excel-macro-save-as-csv-with-separator) – Automate This Sep 28 '14 at 20:28

1 Answers1

1

Code marked as solution for your question in another stackoverflow question.

 ActiveWorkbook.SaveAs Filename:="C:\Temp\Fredi.csv", FileFormat:=xlCSV, CreateBackup:=False, local:=True 

ref: Save as CSV with semicolon separator

Community
  • 1
  • 1
Abkarino
  • 1,426
  • 1
  • 12
  • 19