Convert xls / xlsx files (all sheets) to csv using VBScript (delimited by semicolons)

℡╲_俬逩灬. 提交于 2019-12-06 05:01:31

You are trying to save a WorkSheet, yet you are using the WorkBook object. Try using the WorkSheet object you've extracted with the For statement

 Dim WorkSheet
 For Each WorkSheet In objWorkBook.Sheets 
  If objXL.Application.WorksheetFunction.CountA(WorkSheet.Cells) <> 0 Then
   WorkSheet.SaveAs strPath & "\" & WorkSheet.Name & ".csv", 6
  End If
 Next

This works for me.

I've changed your "sheet" to "WorkSheet" just to emphasize the difference. Of course "sheet" or any other object name will work just fine.

My suggestion would be to use different language for this. Editing registry entries for the sake of changing delimiter is "hacky" to say at least.

It can possibly be done by simple Python script and using xlrd and csv packages. This would make it usable on multiple platforms. You can easily convert your Python script to .exe using Py2exe.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!