# WINDOWS - Convert XLS to CSV on command line



## maleni (Jun 10, 2016)

Hello guys,

I am using following script:


```
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">if WScript.Arguments.Count < 2 Then
    WScript.Echo "Please specify the source and the destination files. Usage: ExcelToCsv <xls/xlsx source file> <csv destination file>"
    Wscript.Quit
End If

csv_format = 6

Set objFSO = CreateObject("Scripting.FileSystemObject")

src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))

Dim oExcel
Set oExcel = CreateObject("Excel.Application")

Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)

oBook.SaveAs dest_file, csv_format

oBook.Close False
oExcel.Quit</code>
```

How would I save .csv without asking to rename it (override - without question?).

Thanks


----------



## John_w (Jun 10, 2016)

Welcome to MrExcel forums.

Untested, by try SaveCopyAs instead of SaveAs.


----------



## CMAnslow (Jun 10, 2016)

Also untested. Try turning off displaying alerts before the save, Then back on after the save.


```
oExcel.DisplayAlerts = False
oBook.SaveAs dest_file, csv_format
oExcel.DisplayAlerts = True
```


----------



## maleni (Jun 14, 2016)

Thank you guys. 

CMAnslow answer did it.

If it is possible, I would need also following assistance.

i would like to save also like this:


```
Sub fds()
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.Copy
    Workbooks.Add
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\matej\Desktop\pregled\prenos\visible.csv", FileFormat:= _
        xlCSV, CreateBackup:=False
End Sub
```

this now saves only active (filtered) data and outputs it as .csv. I need to overwrite existing filename without asking.

Another question.

I have one worksheet where I import data from other worksheets and one row, where I import data via OBDC. This row contains IDs. Is there a way, I can scan a range in worksheet, something like this:

foreach id as id {
check where this id exist and get name of that person
}

I need this on run - automatically wihout pressing a button.


----------



## maleni (Jun 16, 2016)

Anyone? I have a deadline here :/


----------

