我需要打开一个txt文件,找到一个特定的字符串,在其下方写几行,保存生成的文件并关闭它。这是我到目前为止的内容:
Sub EditMyTXT()
Dim FileNum As Integer
Dim DataLine As String
FileNum = FreeFile()
Open "E:\Host.txt" For Input As #FileNum
While Not EOF(FileNum)
Line Input #FileNum,DataLine
If DataLine = "TextToFind" Then
move to the next line
write text "TextToWriteBelow TextToFind"
move to the next line
write text "MoreTextToWriteBelow"
Else: End If
Wend
Save FileNum
Close FileNum
End Sub
我找不到以允许我读取写入内容的方式打开txt文件的方法。有任何想法,建议吗?