Option Explicit
On Error Resume Next
Dim fs
Set fs = CreateObject("Scripting.FileSystemObject")
If WScript.Arguments.Count < 3 Then
MsgBox "Usage: Excel2CSV "
WScript.Quit
End If
Dim cvsFile, excelFile ,sheetName
excelFile = WScript.Arguments(0)
cvsFile = WScript.Arguments(1)
sheetName = WScript.Arguments(2)
If fs.FileExists(excelFile) = False Then
'WScript.Echo "File " & docFileName & " doesn't exist!"
MsgBox "File " & excelFile & " doesn't exist!"
WScript.Quit
End If
Dim excelApp, workbook
Set excelApp = CreateObject("Excel.Application")
excelApp.Visible = false
excelApp.DisplayAlerts = False
Set workbook = excelApp.Workbooks.Open(excelFile)
excelApp.Columns("A:F").EntireColumn.AutoFit
excelApp.AlertBeforeOverwriting = false
excelApp.Sheets(sheetName).Select
workbook.SaveAs cvsFile, xlCSV
workbook.Close False
excelApp.Quit
WScript.Quit(Err.Number)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/13996372/viewspace-678528/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/13996372/viewspace-678528/