Edit csv text file with VBA
Edit the filename and header information as per your requirement....
Sub WriteHeaderToCSV()
Dim strFile As String
Dim varData As Variant
Dim fso, f
strFile = "c:\test.csv"
strHeader = "Col1,col2,col3"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(strFile, 1)
varData = f.ReadAll
f.Close
fso.DeleteFile strFile, True
Set f = fso.OpenTextFile(strFile, ForWriting, True)
f.Write strHeader & vbCrLf
f.Write varData
f.Close
End Sub
--
If this post helps click Yes
---------------
Jacob Skaria
"sJ" wrote:
I receive a csv text file in Excel that I need to change the first row of
data in. Doing this in Excel and saving the file converts numbers such as
000200 to 200 etc. Is there a way to do this with the VBA Open and Print
statements?
|