Thanks to other members of this forum, I’ve managed to patch together this basic Word macro (code at end of the attachment) to allow a user to search for keywords within an 18-page guide for an online EV charging station network.
The macro works as intended, except for one little quirk. When it finds a series of several hits for a user-specified keyword, the very first hit of the keyword is not highlighted. From that point on, each progressive hit is highlighted (beginning with the originally-unhighlighted first hit), as well as any hit that precedes or follows the current hit (see image in the attachment for a screen-shot resulting from the first message box, and a simulation of the progressive highlighting of the keyword). The highlight color for the current hit appears darker than the color for the hits that precede and follow it, presumably because its highlight color consists of an encoded gray color, blended with the default yellow color (just my novice observation, why it appears to be darker probably has some other explanation).
I’ve tried resequencing some lines of code preceding the first message box, but nothing that I’ve tried seems to make the first hit appear highlighted.
I suppose I could make the message box prompt more descriptive for the user, but that would also make it more unreadable. I would prefer a more elegant solution, so that the first hit is highlighted, just like each successive hit. Can anyone suggest a modification to my macro’s code to accomplish this? Thanks for any feedback . . .