Disappearing Selection Highlighting in Word 2013 RRS feed

  • Question


    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.

    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.

    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 couses the window to repaint seems to restore the highlighting.

    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.

    If I can't find a solution to the problem, I'd at least like some kind of work-around.

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
          <tab id="MyTab">
            <group id="MyGroup">
              <button id="Button1"
      Public Function GetEnabled(control As Office.IRibbonControl) As Boolean
            Dim returnValue As Boolean = True
                Select Case control.Id
                    Case "Button1"
                        For Each storyRange As Word.Range In myAddIn.Application.ActiveDocument.StoryRanges
                            'Causes Word 2013 to lose selection highlighting
                            If storyRange.Revisions.Count > 0 Then returnValue = False
                    Case Else
                        returnValue = True
                End Select
                ' This space for rent
            End Try
            Return returnValue
        End Function

    Friday, November 1, 2013 1:55 AM

All replies

  • Hi

    I go to File>Option>Add-in however I did not find a Add-in that have Getenabled callback function.

    Would you mind share a download path that I can get it installed in my computer.

    Then I can reproduce your situation and try to resolve the issue.

    Tuesday, November 5, 2013 1:12 PM
  • I've been experiencing the same issue but have been able to work around it by accessing certain properties in a separate thread
    Tuesday, February 25, 2014 7:32 PM