Guest User

Untitled

a guest
Jun 19th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. if WScript.Arguments.Count < 2 Then
  2. WScript.Echo "Please specify the source and the destination files. Usage: ExcelToCsv <xls/xlsx source file> <csv destination file>"
  3. Wscript.Quit
  4. End If
  5. Set objFSO = CreateObject("Scripting.FileSystemObject")
  6. src_file = objFSO.GetAbsolutePathName(Wscript.Arguments.Item(0))
  7. dest_file = objFSO.GetAbsolutePathName(WScript.Arguments.Item(1))
  8. Dim oExcel
  9. Set oExcel = CreateObject("Excel.Application")
  10. Dim oBook
  11. Set oBook = oExcel.Workbooks.Open(src_file)
  12. oBook.SaveAs dest_file, 3
  13. oBook.Close False
  14. oExcel.Quit
  15. Set objFile = objFSO.OpenTextFile(dest_file, 1)
  16. strText = objFile.ReadAll
  17. objFile.Close
  18. strNewText = Replace(strText, " ", ";")
  19. Set objFile = objFSO.OpenTextFile(dest_file, 2)
  20. objFile.WriteLine strNewText
  21. objFile.Close
Add Comment
Please, Sign In to add comment