0

I'm developing an add-in for MSWord using Microsoft web add-in API. I'd like to underline or highlight some given words, but only in the scope of that session. I don't want to change the document's state. In other words, I don't want to persist the new text formatting when the document is saved.

I know how to format text, but the document's state is changed. I have this code at the moment:

word_range.font.underline = Word.UnderlineType.wave;

I want to achieve a behavior similar to Grammarly plug-in, where the underline is only to point out something is wrong with those words, but again, without persisting the underlining.

I found a similar question (word - highlight search results without permanently changing document formatting), but it was asked a few years ago and the solution is not exactly what I'm looking for.

1 Answers1

1

I'm afraid that there is no way to highlight that will automatically disappear if the user saves the document. The answer that you linked to, or this one is the best that can be done in Office.js right now. It is a good idea, however, so please suggest it at Office Developer Suggestion Box.

Rick Kirkham
  • 9,038
  • 1
  • 14
  • 32
  • I understand. But how do they do this in Grammarly add-in? They underline text in a custom manner, it's not the same underline as you would do manually with the mouse, and it doesn't affect the document content itself. – Zuhaitz Beloki Aug 05 '19 at 10:36
  • 1
    Grammerly for Office seems to have its own installer. That means its not an Office Web Add-in using Office.js. – Rick Kirkham Aug 05 '19 at 17:42