我已经实现了以下脚本,但无法将其保存为UTF-8格式。
如何使用VBScript以UTF-8 CSV格式从Excel保存转换后的CSV?
Dim strExcelFileName
Dim strCSVFileName
strExcelFileName = "C:\Users\test.xlsx"
Set fso = CreateObject("Scripting.FileSystemObject")
strScript = WScript.ScriptFullName
strScriptPath = fso.GetAbsolutePathName(strScript & "\..")
LPosition = InStrRev(strExcelFileName, "\")
If LPosition = 0 Then
strExcelFileName = strScriptPath & "\" & strExcelFileName
strScriptPath = strScriptPath & "\"
Else
strScriptPath = Mid(strExcelFileName, 1, LPosition)
End If
Set objXL = CreateObject("Excel.Application")
Set objWorkBook = objXL.Workbooks.Open(strExcelFileName)
objXL.DisplayAlerts = False
For Each sheet In objWorkBook.Sheets
If objXL.Application.WorksheetFunction.CountA(sheet.Cells) <> 0 Then
sheet.SaveAs strScriptPath & sheet.Name & cell & ".csv", 6 'CSV
End If
Next
objWorkBook.Close
objXL.Quit
Set objXL = Nothing
Set objWorkBook = Nothing
Set fso = Nothing
答案 0 :(得分:-1)
在保存行中尝试使用62
代替6
,如下所示:
sheet.SaveAs strScriptPath & sheet.Name & cell & ".csv", 62