我从网上找了一个vbs代码可以替换word文档里面的内容但是每次都要打开文档,能不能修改成在不打开文档的情况下替换word文档的内容。- Const wdReplaceAll = 2
-
- Set objWord = CreateObject("Word.Application")
- objWord.Visible = True
-
- Set objDoc = objWord.Documents.Open("C:\Scripts\Test.doc")
- Set objSelection = objWord.Selection
-
- objSelection.Find.Text = "11"
- objSelection.Find.Forward = TRUE
- objSelection.Find.MatchWholeWord = TRUE
-
- objSelection.Find.Replacement.Text = "22"
-
- objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll
复制代码
|