Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save an Excel file as a CSV

Status
Not open for further replies.

AnaFlor

Programmer
Mar 17, 2004
65
PT
Hello,

I am trying to do in vb script the following:
- I open a excel file, go to the spreadsheet 2 and save that spreadsheet as a csv file. Then, I close both documents and delete the excel file, just remaining the csv file.

Can you help me doing this?

Thanks
 
Hello Anaflor,

Something like this.
Code:
const xlCSV=6
xlfile="d:\test\abc.xls"
csvfile="d:\test\def.csv"
set fso=createobject("scripting.filesystemobject")
if not fso.fileexists(xlfile) then
    wscript.echo "XL file does not exist. Operation aborted."
    wscript.quit(1)
end if
set oxl=createobject("excel.application")
'oxl.visible=true
set owbk=oxl.workbooks.open(xlfile)
oxl.displayalerts=false
owbk.worksheets(2).saveas csvfile, xlCSV
owbk.close
'oxl.displayalerts=true
oxl.quit
set osheet=nothing
set owbk=nothing
set oxl=nothing
fso.deletefile xlfile
set fso=nothing
regards - tsuji
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top