How can I format text without changing document state in MSWord web add-in API?

我怕爱的太早我们不能终老 提交于 2021-01-29 05:19:03

问题


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:


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.



来源:https://stackoverflow.com/questions/56291120/how-can-i-format-text-without-changing-document-state-in-msword-web-add-in-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!