Word := ComObjCreate("Word.Application") ; Create an MS Word object
Word.Visible := true
file := "C:\Users\User\Desktop\WordFile.docx" ; Path to an existing file
Word.Documents.Open(file) ; Open the file
; Clear any previous formatting
Word.Selection.Find.ClearFormatting()
Word.Selection.Find.Replacement.ClearFormatting()
; Replace all instances of the word "before" with the word "after"
Word.Selection.Find.Execute("before", 0, 1, 0, 0, 0, 1, 1, 0, "after", 2)