I'm having trouble highlighting the middle of a line using COM on word. The following code is not working as it highlights the entire line instead of just the text in between:
Code: Select all
Word_App := ComObjCreate("Word.Application")
Word_File := Word_App.Documents.Add()
Word_App.Visible := 1
Word_App.Activate
Word_App.Selection.TypeText("Unhighlighted Text`t")
Word_App.Selection.Range.HighlightColorIndex := 6
Word_App.Selection.TypeText("Highlighted Text`t")
Word_App.Selection.Range.HighlightColorIndex := 0
;Word_App.Options.DefaultHighlightColorIndex := 0
Word_App.Selection.TypeText("Unhighlighted Text 2`n")
Thank you so much for any help you can provide!