When you write CSV data after opening a file using file number #1 excel adds
the extra quotes. You need to open the file using a scripting language open
and writes.
Here is an example file
Sub WriteCSV()
Const Delimiter = ","
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const MyPath = "C:\temp\"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
Set fswrite = CreateObject("Scripting.FileSystemObject")
WriteFileName = "text.csv"
'open files
WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)
LastRow = Cells(Rows.Count, "A").End(xlUp).Row
For RowCount = 1 To LastRow
If Range("D" & RowCount) > Date Then
For ColCount = 1 To 12
If ColCount = 1 Then
OutPutLine = Cells(RowCount, ColCount)
Else
OutPutLine = OutPutLine & Delimiter & Cells(RowCount, ColCount)
End If
Next ColCount
tswrite.writeline OutPutLine
End If
Next RowCount
tswrite.Close
End Sub
Richard said:
The standard write command encloses text data within quotes.
I need to create text file file that looks lie this:
[category]
x = Hi
But, for example, that following commands:
Open text.txt for output as #1
x = "Hi"
Write #1, x
Produces a text file with line: "Hi"
How do I write a macro that produces a text file with text data that is not
enclosed by quote marks?