AppleScript to delete any non-highlighted word in a Word doc

Hello to all, and thank you for keeping at it! Robert’s latest script works, though another weird thing happened.

I deleted everything but the text highlighted in yellow. I ran the script which returned. The correct count wa actually 58.

After doing some additional testing, I realized that the script still returns 2 words highlighted in Bright Green even though there no longer is any text highlighted in Bright Green in the document.

I repeated the some test on something I quickly typed in a separate Word doc, and the count was correct there, so the problem above could be due to that specific file or something not accounted for yet.

You have to save the document first

Yep, I do. the issue still occurs after that.