我尝试使用代码(Olle Sjögren 先生在 8 月 15 日 13:08 的回答)将文件夹 d:\eBobo 中多个 xml 文件中的一行替换为两行
例如,我想更改一行(在该文件夹中的所有 xml 文件中都是相同的):
啊啊啊啊
成行(也在所有 xml 文件中):
bbbbbbbbbb
呸呸呸呸
这是我的尝试:
Sub ReplaceStringInFile()
Const sSearchString As String = "d:\eBobo\*.xml"
Dim sBuf As String
Dim sTemp As String
Dim iFileNum As Integer
Dim sFileName As String
Dim sFilePath As String
sFileName = Dir(sSearchString)
Do While sFileName <> ""
sFilePath = "d:\eBobo\" & sFileName 'Get full path to file
iFileNum = FreeFile
sTemp = "" 'Clear sTemp
Open sFilePath For Input As iFileNum
Do Until EOF(iFileNum)
Line Input #iFileNum, sBuf
sTemp = sTemp & sBuf & vbCrLf
Loop
Close iFileNum
sTemp = Replace(sTemp, "aaaaaaaaaa", "bbbbbbbbbb" <br /> "cccccccccc")
iFileNum = FreeFile
Open sFilePath For Output As iFileNum
Print #iFileNum, sTemp
Close iFileNum
sFileName = Dir() 'Get the next file
Loop
End Sub
我收到一条消息语法错误。任何帮助将不胜感激。
谢谢您的回答!