none
Word 2010 naviagtion pane loses state when accessing ActiveDocument.Shapes RRS feed

  • Question

  • I have a bug where the Navigation pane in Word 2010 loses it's state when I access a Shape of type msoTextBox within the ActiveDocument.Shapes collection.

     

    Here's steps for you to reproduce the problem:

    1. Create a new document

    2. Add Class Module called "EventClassModule"

    Public WithEvents App As Word.Application
    
    Private Sub App_WindowSelectionChange(ByVal Sel As Selection)
        Dim thisShape As Shape
        
        ' If you uncomment this line, the navigation pane will work properly
        'Exit Sub
        
        For Each thisShape In ActiveDocument.Shapes
            If thisShape.Type = msoTextBox Then
                ' by this point the navigation pane will have lost its state
                Exit Sub
            End If
        Next
    End Sub
    
    

    3. Add Module called "Module1"

    Global eventClassModuleInstance As New EventClassModule
    
    Public Sub AutoExec()
        Call initialise
    End Sub
    Public Sub AutoNew()
        Call initialise
    End Sub
    Public Sub AutoOpen()
        Call initialise
    End Sub
    
    Sub initialise()
        Set eventClassModuleInstance.App = Word.Application
    End Sub
    
    

    4. Save as a .dotm macro-enabled template

    5. Create a new document based on this template

    6. Type "hello hello hello"

    7. Insert a Text Box 

    8. Press Ctrl-F to open the Navigation Pane

    9. Type "hello"

    Note that instances of "hello" are highlighted yellow and it says "3 matches" in the Navigation Pane.

    10. Hit Return

    At this point App_WindowSelectionChange() is called, the "hello"s are no longer highlighted and it doesn't say "3 matches" in the Navigation Pane.

     

    Please let me know if this is due to a bug in Word or in my code, and if there is a workaround.

    Thanks,

    Steve

    Monday, September 12, 2011 2:48 PM

Answers

  • Hi Steve

    As far as I can tell, this is a normal state for the Navigation pane. I don't even need your code to see the pane clear itself of contents.

    As an end-user, in a document where no events are running, display the navigation pane and type something in to search for.

    Now click somewhere in the document and press Enter.

    On my machine, the Navigation pane clears.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Liliane Teng Wednesday, September 28, 2011 11:12 AM
    Friday, September 16, 2011 8:31 AM
    Moderator
  • Hi Steve,

    Sorry for the delay.

    This is not a bug in Word. Please check below KB which explains this issue:

    http://support.microsoft.com/kb/2285381
    (Search results are lost after you edit a document in Word 2010)

    Symptoms:

    You perform a search by using the Navigation pane in Microsoft Word 2010.
    After you edit a document, the search results are lost.

    Workaround:

    To work around this issue, click Next Search Result (down arrow) or Previous Search Result (up arrow) in the Navigation pane.

    If you have any concerns, please feel free to follow up.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Liliane Teng Wednesday, September 28, 2011 11:12 AM
    Thursday, September 22, 2011 7:15 AM

All replies

  • Hi Steve

    As far as I can tell, this is a normal state for the Navigation pane. I don't even need your code to see the pane clear itself of contents.

    As an end-user, in a document where no events are running, display the navigation pane and type something in to search for.

    Now click somewhere in the document and press Enter.

    On my machine, the Navigation pane clears.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by Liliane Teng Wednesday, September 28, 2011 11:12 AM
    Friday, September 16, 2011 8:31 AM
    Moderator
  • Hi Steve,

    Sorry for the delay.

    This is not a bug in Word. Please check below KB which explains this issue:

    http://support.microsoft.com/kb/2285381
    (Search results are lost after you edit a document in Word 2010)

    Symptoms:

    You perform a search by using the Navigation pane in Microsoft Word 2010.
    After you edit a document, the search results are lost.

    Workaround:

    To work around this issue, click Next Search Result (down arrow) or Previous Search Result (up arrow) in the Navigation pane.

    If you have any concerns, please feel free to follow up.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Liliane Teng Wednesday, September 28, 2011 11:12 AM
    Thursday, September 22, 2011 7:15 AM
  • Hi Steve,

    I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions? If you have any concerns, please feel free to follow up.

    Have a nice day.

    Best regards


    Liliane Teng [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, September 26, 2011 10:06 AM
  • Thanks for the reply, unfortunately it doesn't match my case, since my code is not editing or changing the document in any way, the offending code is as follows:

        For Each thisShape In ActiveDocument.Shapes
            If thisShape.Type = msoTextBox Then
                ' by this point the navigation pane will have lost its state
                Exit Sub
            End If
        Next

    If this is removed, the results remain in the navigation pane. All it does is iterate through ActiveDocument.Shapes and do an equality test, why should this reset the navigation pane results?

    Thanks,
    Steve

    Tuesday, January 3, 2012 10:45 AM
  • Thanks for the reply, unfortunately it doesn't match my case, since my code is not editing or changing the document in any way, the offending code is as follows:

     

        For Each thisShape In ActiveDocument.Shapes
            If thisShape.Type = msoTextBox Then
                ' by this point the navigation pane will have lost its state
                Exit Sub
            End If
        Next

    If this is removed, the results remain in the navigation pane. All it does is iterate through ActiveDocument.Shapes and do an equality test, why should this reset the navigation pane results?

    Thanks,
    Steve
    Tuesday, January 3, 2012 10:47 AM