Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Importing text file, only option to edit existing file | Excel Discussion (Misc queries) | |||
2 users open same file and both can edit/change the file | Excel Discussion (Misc queries) | |||
Use XL 2 Edit a .txt File? | Excel Programming | |||
Use XL 2 Edit a .txt file? | Excel Programming | |||
Can I edit .iqy file from code? | Excel Programming |