选择突出显示消失 [英] Selection Highlighting Disappears

查看:83
本文介绍了选择突出显示消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义功能区的Word AddIn。 自定义功能区包含一个按钮。 该按钮具有GetEnabled回调函数,该函数通过ActiveDocument.StoryRanges执行For Each循环检查以查看是否有任何StoryRange具有修订版。 
如果是,则GetEnabled函数返回False。

I have a Word AddIn with a custom ribbon.  The custom ribbon contains a button.  The button has a GetEnabled callback function that does a For Each loop through the ActiveDocument.StoryRanges checking to see if any StoryRange has a Revision.  If it does, the GetEnabled function returns False.

AddIn处理Application.WindowSelectionChange事件。 更改文本选择时,事件处理程序使功能区无效并调用按钮的GetEnabled函数。

The AddIn handles the Application.WindowSelectionChange event.  When the text selection is changed, the event handler Invalidates the ribbon and the button's GetEnabled function is called.

当GetEnabled函数执行检查以查看StoryRange.Revision.Count的语句时> 0,所选文本丢失其选择突出显示。 关于选择的其他所有内容保持不变。 导致窗口
重新绘制的任何内容似乎都会恢复突出显示。

When the GetEnabled function executes the statement that checks to see if the StoryRange.Revision.Count > 0, the selected text loses its selection highlighting.  Everything else about the selection stays the same.  Anything that causes the window to repaint seems to restore the highlighting.

此行为仅发生在Word 2013中。 在Word 2010中运行的相同AddIn不会丢失选择突出显示。 此行为不仅限于对StoryRange.Revisions.Count的引用。 似乎在Selection.Range之外对Word对象
的任何引用都会导致Selection失去其突出显示。

This behavior only occurs in Word 2013.  The same AddIn running in Word 2010 does not lose the selection highlighting.  This behavior is not limited to references to the StoryRange.Revisions.Count.  It seems that any reference to a Word object outside the Selection.Range causes the Selection to lose its highlighting.

有人可以建议解决方案或解决方法吗?

Can anyone suggest a solution or a work-around?

推荐答案

我尝试在我身边重现你的问题,但它工作正常,你能告诉我你的代码还是
截图?

I try to reproduce your issue in my side , but it worked fine ,Could you show me your code or screenshot?

我将代码测试为bolow:

I test the code as bolow:

在功能区XML中:

 <button id ="MyButton " label ="TestButton" imageMso="HappyFace"  getEnabled="SampleCallback"/>



功能区:


In Ribbon:

                    For Each story As Word.Range In Globals.ThisAddIn.Application.ActiveDocument.StoryRanges
                        If story.Revisions.Count > 0 Then returnValue = False
                    Next

在加载项中:

    Private Sub Application_WindowSelectionChange(Sel As Microsoft.Office.Interop.Word.Selection) Handles Application.WindowSelectionChange
        Myribbon1.myRibbon.Invalidate()
    End Sub

每次选择都已更改,所选文本与之前相同。

Every selecttion changed,the selected text same as before.

我的电脑e 环境是:

Windows 8(64)& Office 2013(32)

Windows 8 (64)&Office 2013 (32)

问候,


这篇关于选择突出显示消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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