I need to convert a list of excel files into semicolon csv file through a vbs file because a program I use only imports vbs files with semicolon as separator, I programmed this small file in vbs, but it manages to export it as csv with the comma, not semicolon.
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Users\loren\Desktop\eFolder" 'folder where my Excel files are saved
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
csv_format = 6
Set objFSO = CreateObject("Scripting.FileSystemObject")
src_file = objStartFolder & "\" & objFile.Name 'Input files
dest_file = objStartFolder & "\OUTPUT\" & objFile.Name & ".csv" 'Output files
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
Next
CodePudding user response:
I solved it by saving the file with Local argument's parameter set to True. Thanks to the response from @VBasic2008
Set objFSO = CreateObject("Scripting.FileSystemObject")
objStartFolder = "C:\Users\loren\Desktop\eFolder"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
csv_format = 6
Set objFSO = CreateObject("Scripting.FileSystemObject")
src_file = objStartFolder & "\" & objFile.Name
dest_file = objStartFolder & "\OUTPUT\" & objFile.Name & ".csv"
Dim oExcel
Set oExcel = CreateObject("Excel.Application")
Dim oBook
Set oBook = oExcel.Workbooks.Open(src_file)
oBook.SaveAs dest_file, csv_format, , , , , , , , , , True
oBook.Close False
oExcel.Quit
Next