I have the following Excel VBA script which I use in Excel for Mac 2011 to export all the worksheets of an Excel file to .csv files.
Sub save_all_csv()
On Error Resume Next
Dim ExcelFileName As String
ExcelFileName = ThisWorkbook.Name
For Each objWorksheet In ThisWorkbook.Worksheets
ExcelFileNameWithoutExtension = RemoveExtension(ExcelFileName)
CsvFileName = ExcelFileNameWithoutExtension & "__" & objWorksheet.Name & ".csv"
Application.DisplayAlerts = False
objWorksheet.SaveAs Filename:="data:storage:original_excel:" & CsvFileName, FileFormat:=xlCSV, CreateBackup:=False
Application.DisplayAlerts = True
Next
Application.DisplayAlerts = False
Application.Quit
End Sub
Function RemoveExtension(strFileName As String)
strFileName = Replace(strFileName, ".xlsx", "")
strFileName = Replace(strFileName, ".xls", "")
RemoveExtension = strFileName
End Function
The problem is that they save as Western Mac OS Roman which I can't get to convert to UTF-8 via PHP, so I would like to have VBA save these files in UTF-8 format in the first place.
I've found some solutions for saving text from VBA via a Stream object and with CreateObject but it's apparently not possibile on the Mac to use CreateObject to write directly to files.
How can I save worksheets as CSV files in UTF-8 format with Excel for Mac 2011?
FileFormat:=xlCSVUTF8
? – Gonzalingui