Create a VBScript to search and replace words in a XML document
Posted on 2014-08-02
I am hoping someone can help me. I am trying to create a VBScript to search an XML document and change some numbers. Basically it will search through the whole document and when it finds the number it will replace this with another number, it will then save and close.
I have been able to create this with word but I am struggling to replicate this with XML.
My word script at the bottom. Any help would be greatly appreciated. Thanks
'declare and instaciate wrdApp
Dim wrdApp: Set wrdApp = WScript.CreateObject("Word.Application")
'Open the document
Set wrdDoc = wrdApp.Documents.Open("C: \Test.docx")
'set the value for the replace "constant"
wdReplaceAll = 2
.Text = "aaa"
.Replacement.Text = "bbb"
.Forward = True
.Wrap = 1
.Format = False
.MatchCase = False
.MatchWholeWord = False
'the Replace argument is the 11'th argument
.Execute , , , , , , , , , , wdReplaceAll
Set wrdApp = Nothing
Set wrdDoc = Nothing