如何在不更改 MSWord Web 加载项 API 中的文档状态的情况下设置文本格式? [英] How can I format text without changing document state in MSWord web add-in API?

查看:68
本文介绍了如何在不更改 MSWord Web 加载项 API 中的文档状态的情况下设置文本格式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Microsoft Web 插件 API 为 MSWord 开发插件.我想强调或突出某些给定的词,但仅限于该会议的范围内.我不想更改文档的状态.换句话说,我不想在保存文档时保留新的文本格式.

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;

我想实现一个类似于 Grammarly 插件的行为,其中下划线只是指出那些词有问题,但同样,没有坚持下划线.

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.

我发现了一个类似的问题(word - 在不永久更改文档格式的情况下突出显示搜索结果),但有人问了几年前,解决方案并不是我正在寻找的.

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.

推荐答案

恐怕没有办法突出显示,如果用户保存文档会自动消失.您链接到的答案,或这个是最好现在可以在 Office.js 中完成.不过,这是一个好主意,因此请在 Office 开发人员意见箱中提出建议.

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.

这篇关于如何在不更改 MSWord Web 加载项 API 中的文档状态的情况下设置文本格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆