如何在VSTO中突出显示相同的范围? [英] How to Highlight the same Range in VSTO?

查看:111
本文介绍了如何在VSTO中突出显示相同的范围?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下函数突出显示相同的范围,

 range.Find.HitHighlight(range.Text.Substring(0, range.Text.Length)); 

但是当我这样做时,MS Word会显示一条消息,说"Word已到达文档的末尾。你想从头开始吗?"如果我选择"是"有用。但每次运行此代码时,它都会给出相同的消息。我正在寻找
如何在没有消息框的情况下进行突出显示。


我最初使用以下代码片段突出显示,

 range.HighlightColorIndex = WdColorIndex.wdYellow 

在这种方法中,它实际上改变了原始文档,即使你可以使用代码在稍后阶段删除突出显示。因此我尝试使用HitHighlight功能来突出显示,因为它不会创建任何永久性的亮点。


(我基本上需要突出显示给定的范围而不对原始文档进行任何更改本身。)


对此有何看法?







解决方案


如何设置范围?


使用Selection.Range作为范围时,警报不会仅显示如果所选段落是最后一段,我们无法在其他情况下隐藏警报。


请分享有关您希望此功能如何执行的更多详细信息,我们会尝试查找是否有任何解决方案或解决方法。


问候,


Celeste


I'm trying to highlight the same Range using the following function,

range.Find.HitHighlight(range.Text.Substring(0, range.Text.Length));

But when I do this MS Word gives a message saying that "Word has reached the end of the Document. Do you want to continue from the beginning?" If I select "Yes" it works. But every time this code runs it gives the same message. I'm looking into how I can do the Highlight without the message box.

I've initially used the following snippet to highlight,

range.HighlightColorIndex = WdColorIndex.wdYellow

In this approach, it actually alters the original document even though you can use the code to remove the Highlight at a later stage. Therefore I've tried using the HitHighlight function to do the highlight since it does not create any permanent Highlights.

(I basically need to highlight a given Range without making any changes to the Original document itself.)

Any thoughts on this ?



解决方案

Hi,

How do you set your range?

When using Selection.Range as the range, the alert would not show only if the selected paragraph is the last one, and we could not hide the alert in other situations.

Please share more detail information about how you want this function to perform, and we would try to find if there are any solutions or workarounds.

Regards,

Celeste


这篇关于如何在VSTO中突出显示相同的范围?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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