Office JavaScript API:高亮显示文档中的文本 [英] Office JavaScript API: highlighting text in a document

查看:61
本文介绍了Office JavaScript API:高亮显示文档中的文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft Office JavaScript API进行辅助项目.我一直依靠文档找到自己的出路,但我碰壁试图在文档中找到某些内容(也许因为不存在而可能不存在).

I'm working on a side project using the Microsoft Office JavaScript APIs. I have been relying on the documentation to find my way around, but I've hit a wall trying to find something in the docs (perhaps it isn't there because it doesn't exist).

最近,我尝试实现一些功能以突出显示Word文档中的某些文本.请注意,我不想修改文档;换句话说,我宁愿不使用

Recently I attempting to implement some functionality to highlight some text within a Word document. I don't want to modify the document, mind you; in other words I would rather not use something like ContentControl.insertHtml as that would change the actual content. What I want is to make the text temporarily highlighted (e.g., until the user clicks a "Cancel" button), much like what you see when you perform a search with Ctrl+F (and text matching your search is highlighted in yellow).

使用Office JavaScript API是否可能?

Is this possible using the Office JavaScript APIs?

推荐答案

尝试获取对Range对象的引用,然后设置

Try getting a reference to the Range object and then setting Range.font.highlightcolor. Have a handler for the Cancel button click event that reverses the color change.

这篇关于Office JavaScript API:高亮显示文档中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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