


<pre>Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:your_file.txt", ForReading)
iLineNumber = 0
Do Until objFile.AtEndOfStream
strLine = objFile.Readline
iLineNumber = iLineNumber + 1
<b>If iLineNumber = 132</b> Then
strNewContents = strNewContents &<b> "Your new line"</b> & vbCrLf
else
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("C:your_file.txt", ForWriting)
objFile.Write strNewContents
objFile.Close</pre>
-CarlosDL
------------------------ 

Carlos,
Thanks for the code but I am unable to get the .AtEndOfStream to work. It does not recognize the code. I have referenced Microsoft Office 12.0 Object Library without success.
Thanks Bob
Sorry Bob, I tested it as a vb script.
I think you will need to add a reference to The Microsoft Scripting Runtime Object Library
Let me know if this solves the problem.
How to add password to text file by VBA code?
Hi VBAzip,
If you start a new thread for your question, you’re more likely to get a helpful response. Please include as many details as possible!
Thanks!
- Melanie