Hello!
I have; XlsxToCsvConverter.vbs (see the code at the bottum).
How do I make this code convert Csv UTF-8 to the same Csv with semi-colon separation? I tried to change XLSX and xlsx with CSV without any luck. Yes I am a newbie.
I have; XlsxToCsvConverter.vbs (see the code at the bottum).
How do I make this code convert Csv UTF-8 to the same Csv with semi-colon separation? I tried to change XLSX and xlsx with CSV without any luck. Yes I am a newbie.
Code:
WScript.Echo "Converting from xlsx to vbs. Press ok to continue." 'prints startup message
on error resume next
Dim fso, fullpath, oExcel, wBook, getbase
Set fso = CreateObject("Scripting.FileSystemObject")
fullpath = fso.GetAbsolutePathName(folderName) 'get the path of the current folder
objStartFolder = fullpath
Set objFolder = fso.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
Set oExcel = CreateObject("Excel.Application")
oExcel.DisplayAlerts = False
'Checks for existing CSV folder and creates one if none exist
If Not fso.FolderExists(fullPath + "\CSV") Then
fso.CreateFolder(fullpath + "\CSV")
End If
For Each objFile in colFiles 'searches through all files in the current folder
If UCase(fso.GetExtensionName(objFile.name)) = "XLSX" Or fso.GetExtensionName(objFile.name) = "xlsx" Then 'finds xls files
Set wBook = oExcel.Workbooks.Open(objFile) 'open the files in Excel
getbase = fso.getbasename(fullpath + "\" + objFile) 'get the name of the file
'save the new file. With the same name. As csv. And True saves the files against Microsoft excel including control panel settings too get semicolon
'separation opposed to comma separation, change to "local" to use local settings.
wBook.SaveAs fullpath + "\CSV\" + getbase, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, True
wBook.Close False 'closes workbook without saving changes; change to True if you want to save changes to the workbook
End If
Next
oExcel.Quit
'prints error messages
If Err.Number <> 0 Then
MsgBox "Error: " & Err.Description
End If
WScript.Echo "Done."