Word := ComObjCreate("Word.Application") ; Create a MS Word object
Word.Visible := true
file := "C:\Users\User\Desktop\WordFile.docx" ; Path to an existing file
Doc := Word.Documents.Open(file) ; Open the file
; Clear any previous formatting
Word.Selection.Find.ClearFormatting()
Word.Selection.Find.Replacement.ClearFormatting()
; Highlight the found words yellow. The code for yellow is 7.
Word.Options.DefaultHighlightColorIndex := 7
Word.Selection.Find.Text := "highlight me"
Word.Selection.Find.Replacement.Highlight := true
; Find all instances of "highlight me" and highlight it yellow
Word.Selection.Find.Execute(,,,,,,,,,,2)