回复 18# delab-1
未测试.
注意:vbs代码编码是ANSI,export.txt编码是Unicode.- Set fso = CreateObject("Scripting.FileSystemObject")
- Set path = fso.GetFolder(".")
- Set file = fso.OpenTextFile(path & "\export.txt", 1,-1)
-
- Set wordApp = CreateObject("Word.Application")
- Set doc = wordApp.Documents.Open(path & "\export.docx")
-
- Do Until file.AtEndOfStream
- line = file.ReadLine()
- If InStr(line, "=") > 0 Then
- oldstr = Split(line, "=")(0)
- newstr = Split(line, "=")(1)
- With doc.Content.Find
- .Text = oldStr
- .Replacement.Text = newStr
- .Execute ,,,,,,,,,,2
- End With
- End If
- Loop
-
- file.Close
- doc.Save
- doc.Close
-
- wordApp.Quit
- Set fso = Nothing
-
- MsgBox "替换完成!"
复制代码
|