This is a multi-part message in MIME format.
------=_NextPart_000_0022_01C1C67A.5E369630
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
Unless I am mistaken, you cannot do EXACTLY what you have stated BUT the
following does work to produce the same result:
Private Sub cmdTestEditFile_Click()
Dim fso As Scripting.FileSystemObject
Dim tsIn As Scripting.TextStream
Dim tsOut As Scripting.TextStream
Dim strFile As String
Dim strLine As String
strFile = "D:\Test\TestEditLine.txt"
Name strFile As strFile & "xxx"
Set fso = New Scripting.FileSystemObject
Set tsIn = fso.OpenTextFile(strFile & "xxx")
Set tsOut = fso.CreateTextFile(strFile)
Do While Not tsIn.AtEndOfStream
strLine = tsIn.ReadLine
strLine = Replace(strLine, "minister", "teacher", , ,
vbBinaryCompare)'Just an example of an edit
tsOut.WriteLine strLine
Loop
tsIn.Close
tsOut.Close
Set tsIn = Nothing
Set tsOut = Nothing
Set fso = Nothing
Kill strFile & "xxx"
End Sub
It may look a little clumsy but it is a lot faster than you may think.
I hope this helps
Ian Ashton
-----Original Message-----
From: Gopalakrishnan [mailto:ntg@s...]
Sent: Friday, March 08, 2002 4:44 AM
To: professional vb
Subject: [pro_vb] Updating a file
hi,
I am using FileSystemObject to Update a file. But I don't know how to
"Update" a line in the file and save it back. Can somebody help me?
Thanks,
N.T.GOPALAKRISHNAN