Try this:
VB Code:
Dim pos1 As Long, pos2 As Long, i As Long Dim file As String, line As String file = vbNullString Open "c:\test.txt" For Input As #1 Do While Not EOF(1) Line Input #1, line i = i + 1 pos1 = InStr(1, line, "(") pos2 = InStr(1, line, ")") If pos1 > 0 And pos2 > 0 Then line = Left(line, pos1 - 1) & "(" & "replacement" & ")" & Right(line, Len(line) - pos2) End If If i = 1 Then file = line Else file = file & vbCrLf & line End If Loop Close #1 Open "c:\test.txt" For Output As #1 Print #1, file Close #1




Reply With Quote