Word 2016 - VBA open Navigation pane and set display to "Results"

Bobby Jennings 1 Reputation point
2021-07-18T18:34:40.793+00:00

Using VBA, how do I set the Navigation Pane display to the "Results" group rather than "Headings" or "Pages"?

Here is the code I use for auto-opening a document to the Navigation Pane.
Sub AutoOpen()
Application.GoBack
Selection.MoveDown Unit:=wdLine, Count:=10
Selection.MoveUp Unit:=wdLine, Count:=10
Call NavPaneSearch
End Sub

Sub NavPaneSearch()
' NavigationPaneSize Macro
' Charles Kenyon 18 October 2018
Dim iWidth As Integer
iWidth = 218 ' change to suit
With Application.CommandBars("Navigation")
.Visible = True
.Width = iWidth
End With
End Sub

Thank you!

Developer technologies | Visual Basic for Applications
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Tom van Stiphout 1,861 Reputation points MVP Volunteer Moderator
    2021-07-18T23:21:33.27+00:00

    The navigation pane can be opened with:
    ActiveWindow.DocumentMap = True

    However, this is a simple property. There is no object to represent the document map. So alas, what you want does not seem to be possible unless you go to extremes.


  2. Tom van Stiphout 1,861 Reputation points MVP Volunteer Moderator
    2021-07-20T03:18:28.31+00:00

    form subclassing. processing windows messages of the window involved. spy++. I did a quick test and I'm not even sure that would get you there.
    If these concepts are foreign, <NYC accent> Forget about it </>

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.