In my program, I’m using Find.Execute to search for all the word forms of a keyword and highlight them. For example, If my source document contains “perform” and “performance”, Find.Execute(...matchAllWordForms=true...) will find both words, but it will only highlight the ‘perform’ section of performance.
How can I get MSWord to highlight the entire word? The range.Text is changed by Find.Execute to just be “perform”, so I cant iterate through that. I tried doing a Range.Select() and then iterating Selection.End, but the ranges do no match up with the original document.
Any help would be greatly appreciated!
Well, I feel kind of stupid:
I was trying to use
Selection.Extendand completely missed theSelection.Expandoption. For anyone who stumbles across this later:Note that I use Shading for my highlighter (so I can create custom colors with
System.Drawing.Color.FromARGB(Alpha,R,G,B)instead of the default 15 colors).