Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert line in first row of CSV text file with VBA
I have a CSV text file and would like to insert a row at the top using the
VBA Write statement from Excel. I am able to append, but can not add to the first line. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert line in first row of CSV text file with VBA
Try this code:
Sub InsertLineAtBeginningTexFile(strFile As String, strLine As String) Dim hFile As Long Dim FileContents As String Dim NewString As String hFile = FreeFile Open strFile For Binary As #hFile FileContents = Space(FileLen(strFile)) Get #hFile, , FileContents Close #hFile NewString = strLine & vbCrLf FileContents = NewString & FileContents Open strFile For Binary As #hFile Put #hFile, , FileContents Close #hFile End Sub RBS "JA" wrote in message ... I have a CSV text file and would like to insert a row at the top using the VBA Write statement from Excel. I am able to append, but can not add to the first line. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Concatentate text and insert blank line | Excel Worksheet Functions | |||
Reading a text file line by line | Excel Programming | |||
H2 insert a text tag into a line graph | Charts and Charting in Excel | |||
Reading a text file line by line | Excel Programming | |||
import huge text file line-by-line? | Excel Programming |