Sat 3 Jan 2009
Microsoft Excel has limited or no options regarding the export to csv feature. For example, you can not select that exported values will be included inside double quotes.
Here is a script that will do the job:
Sub subExportCSV()
On Error GoTo subexport_exit
Dim strDelimiter As String
strDelimiter = Chr(9)
Dim strQualifier As String
strQualifier = “”"”
Dim arrRng
arrRng = ActiveSheet.UsedRange.Value
Dim f As String
Dim i As Long
Dim j As Long
Dim strTemp As String
f = InputBox(”Enter a filename for saving”, , “c:\test.csv”)
If Trim(f) = “” Then Exit Sub
Open f For Output As #1
strTemp = “”
For i = 1 To UBound(arrRng, 1)
strTemp = “”
For j = 1 To UBound(arrRng, 2)
strTemp = strTemp & strQualifier & arrRng(i, j) & strQualifier & strDelimiter
Next j
Print #1, Left(strTemp, Len(strTemp) – Len(strDelimiter))
Next i
subexport_exit:
Close #1
End Sub