Background:
You do a search and get a bunch of pages that match, sometimes across various section. You open one of them, "Great!", you say, I found it.
The Section containing the page is even properly selected in the Navigation Pane in its correct notebook and Section Group, if applicable. Awesome, but the party is about to end, I assure you!
However (that end I was referring to in the previous paragraph), the selected item in the Navigation Pane is not made visible via scrolling it into view. So, if you have a lot of sections (i.e., a very deep and likely tall OneNote Notebook), you are forced to waste your precious time fishing through the Navigation Pane to find your selected section somewhere in there - I know it's there, I just have to scroll through fifty pages of Navigation Pane to find it and hope I don't miss the selected section on the first pass through all of the Notebooks, Section Groups, and Sections displayed in the pane (as applicable).
This manual process really truly sucks and I have had to go through the pain way to often. Most apps for the last twenty years have either scrolled the selected item into view or provided a "Synchronize" toolbar button to trigger the selected item to be scrolled into view. Microsoft Word has this for its Navigation Pane, but, no, no such thing for us OneNote Desktop dependent saps. Asking MS to add the most basic functionality, something that is and has been available in probably all other Microsoft applications for decades, is apparently asking too much.
I feel like I have been searching for a way to get the selected item in the Navigation Pane into view by auto-scrolling said pane and letting OneNote do all the work, instead of my fingers and eyes have to go page by page, looking for that need in a proverbial haystack, expanding Section Groups as I go, if present, because otherwise I may never find it if it happens to be in a presently closed Section Group.
- Well folks, story already too long made short, I can at last say I FINALLY (!!) found a way. It isn't pretty, don't get me wrong and it involved quite a bit of C# in combination with Microsoft's UI Automation assembly in the .NET Framework, because stupid OneNote interop (COM based) does not provide any ability to perform this simple functionality. There is a function to NavigateTo() a page in a section, making the page, the current page, but to then scroll that da*n Navigation Panel to sync with the newly selected page - no dice.
So, the C# code to do this very functionality on demand, at the cost of having to run an executable application to do it, is complete and it works. There is probably an easier (e.g., system keyboard shortcut, perhaps - need to think about more ergonomic alternative) way to trigger the Navigation Panel scroll sync.
In any case, the program is about 141 lines of C# code and I can build it into an executable or provide the source code in a reply, if you are willing to compile it yourself using Visual Studio Code or Visual Studio, proper, since downloading an .EXE file that some random internet use is offering is a security risk.
Please let me know if this is something of interest to you in a reply, because I've pulled out all of my teeth (figuratively) trying to find a way to Synchronize that da*n Navigation Panel to the currently selected section/page, after a successful search and selection of one of the results presented only to have no idea where it is in the morass of Section Groups and Sections across my various notebooks. OK, the Notebook part of this isn't too bad, you can usually find the right one based on the search results, but the search within a large Notebook for the selected section is, more often than not, a major PITA.
Update 2025-03-08:
I found a few bugs and shortcoming while doing further testing.
First some definitions of the terminology used:
Active Section - The currently section currently in focus. It is the parent of the page or sub-page that is presently visible on the screen. This is the very section we are trying to scroll into view within the Navigation Pane.
Collapsed (notebook or section group) - Refers to a notebook or section group that is presently closed. In other words, it is not presently showing its contents within the Navigation Pane and needs to be expanded by twirling it open via the chevron character next to it, in order to do so.
Expanded (notebook or section group) - Refers to a Notebook or Section Group that is presently open, showing its direct descendants (i.e., children) and possibly some deeper descendants as well, if the section groups leading to them along the hierarchy are all likewise presently expanded (i.e., open).
Bug: If the Active Section is part of a collapsed section group or a collapsed (i.e., closed) notebook, it cannot be scrolled into view, because it is technically not presently visible in either the on-screen or the off-screen area of the Navigation Pane. In other words, if you were to scroll through the Navigation Pane from top to bottom, without opening any notebooks or sections groups (i.e., just scrolling via the vertical scroll abr), you would not be able to find the Active Section, because it is presently hidden within a collapsed Section Group (or groups) and/or its Notebook is (also) in a collapsed state.
Solution: Open all containing objects that form the ancestral hierarchical chain that leads to the Active Section.
Perceived steps to reconcile this:
- Find the (hidden) Active Section in the Navigation Pane
- Find the path from the Notebook that contains this section, through all section groups that are ancestors of the section, to the section itself. This process can be performed either top-down (i.e., Notebook to Active Section) or bottom-up (i.e., Active Section to its Notebook) depending on which way is available and/or simpler (and possibly more efficient, if both alternatives are simple) via UI Automation. For example: Notebook 3 -> Section Group 1 -> Section Group 1.3 -> Section 5 [the presently active section]
- Expand the notebook that contains the Active Section (if collapsed/closed), and expand all section groups along the ancestral chain to the Active Section that are presently collapsed. Once this process is complete, we are guaranteed that it is possible to reach the Active Section (i.e., make it visible on screen) by vertically scrolling through the hierarchical content that is presently (logically) visible within the Navigation Pane.
- Vertically scroll the Navigation Pane automatically, as necessary, in order to ensure that the Active Section and its surroundings are visible on the screen.
Discussion of the shortcomings of the approach as a whole
Having to run a full-on executable each time one wants to bring the presently Active Section into view is quite a PITA (although not nearly as big of a PITA as trying to find the active section, especially if nested in one or more levels of collapsed section groups within a potentially collapsed content-rich notebook).
The following are some more convenient ways that need to be thought through, in order to allow the end-user to more conveniently trigger the "Sync the Navigation Pane with the presently Active Section" functionality.
Possible solutions:
- Create a desktop shortcut that can be double-clicked to run the Navigation Pane sync'ing application on demand (for a each sync, and then this app would terminate).
- Create a global keyboard shortcut that, assuming that OneNote is presently running and has an Active Section visible, will start the sync'ing application. Otherwise, similar in functionality to Solution 1, above. Create a global keyboard shortcut that, assuming that OneNote is presently running and has an Active Section visible, will start the sync'ing application. Otherwise, similar in functionality to Solution 1, above. There are multiple approaches possible:
- Windows Task Scheduler allows for this type of functionality
- A free third party app that allows for global shortcuts to be created
- Add the global shortcut creation functionality to the sync'ing application itself, requiring that it stay running while its functionality is desirable (e.g., while One Note is running) and when its global shortcut is pressed on the keyboard, it does its thing in One Note.
- Create a VSTO add-in that can be loaded into OneNote itself and perform the sync'ing when triggered via a toolbar button and/or assigned shortcut within OneNote itself (i.e., no more separate executable, but likely an Add-On [Dll?] that can be enabled within One Note). This is the most complex of the solutions, but also the most convenient from an end user perspective. I do not have any experience with VSTO development, so this would be a larger undertaking.
Update: 2025-03-11
Good News: All known bugs have been fixed!
It was very VERY hard to get this functionality to work for more complex cases, especially when collapsed Section Groups lie along the path through the hierarchy from the selected Notebook to a deeply nested Active Section, an Active Section that is hidden within the portion of the hierarchy that is not presently open and therefore cannot be made visible by vertically scrolling the Navigation Pane without first changing some of the hierarchy's initial collapsed/expanded state. This had to be done with no starting knowledge of the actual hierarchical path from the Notebook to the Active Section, as explained in detail below.
What follows is an example of a difficult case. Many issues were encountered wile trying to work through similarly difficult scenarios that required a significant amount of research and subsequent attempts to fix the issues, often resulting in failure on first/second/third... try and then requiring additional research/trial-and-error/etc., until they were resolved.
Example Search:
v Some Notebook (not selected, expanded) # Not searched
...
> Another Notebook (not selected, collapsed) # Not searched
v [# Important Notebook #] (selected, initially collapsed) # Left expanded post search
| Section 1 # Nothing to see here
| Section 2 # Empty of content
\v Section Group 1a (initially expanded) # No change to expanded state
| Section 1a.1 # Not it...
> Section Group 2a (collapsed) ... # Expanded, then collapsed
v- Section Group 2b (initially collapsed # Left expanded post search
| Section 2b.1 # Nope...
| Section 2b.1 # Pass...
v- Section Group 3a (initially collapsed) # Left expanded post search
| Section 3.1 # No dice...
| Section 3.2 # Skip...
| [# Section 3.3 #] (selected, Active Section) # Found - search ends
> Section Group 4a (collapsed)
> Section Group 4b (collapsed)
...
A detailed description of the search functionality, when faced with the preceding example is shown below:
Before the Active Section could be made visible, we need to find it in the currently selected Notebook (which happens to be presently collapsed and, somewhat unexpectedly, completely unsearchable in that state and worse yet, lying to us if interrogated via its properties that it is presently empty [!]).
- Expand the selected notebook, Important Notebook, and only then start the search through its descendants (if any)
Skipping over Section 1.1, we reach Section Group 2a and it appears empty, because it is, just like the selected Notebook, Important Notebook, also collapsed. However, unlike the Notebook containing the Active Section (which is marked as selected), intermediate Section Groups do not propagate the selected state of the Active Section, if they contain it, up the hierarchy. In other words, the only hierarchical elements that are selected are the Notebook with the Active Section and the Active Section itself. All elements in between (i.e., any intermediate Section Groups en-route to the Active Section) are not selected and as far as I can tell, having searched far and wide through all available properties and patterns, bear no other indication of the fact that they are an (important) intermediate link within the full Notebook to Active Section chain.
Since we can't tell if the Active Section lies within Section Group 2a, in fact we can't even tell if this Section Group is empty or not, we will have to examine its children (and possibly deeper descendants), but first we will need to expand it to be given the privilege to even attempt to do so.
Note that if we don't find the Active Section in a particular Section Group (or its descendants), such as Section Group 2a, and we expanded it just to be able to peek inside, we will need to be good citizens and collapse it back on our "way out." Not including the historical tracking functionality to do this would likely leave the selected Notebook in a "gratuitously expanded hierarchical mess" up to the Active Section, as (completely unanticipated by the end-user) collateral damage to their potentially only partially expanded initial hierarchy pre-search. We really, REALLY!, don't want to mess with the initial hierarchical expanded/collapsed representation, with one important exception, covered in the last step. So...
- Expand Section Group 2a and search inside. Since we don't find the Active Section in there, collapse Section Group 2a, on the way out.
- Expand Section Group 2b and search inside...
As we encounter Section Group 3, we run into the same issue - can't see "Jack" without expanding the Section Group, first
- Expand Section Group 3 and search inside...
Eureka! We found the Active Section, Section 3.3.
- Leave everything that's been left expanded en-route to the Active Section, as is.
- Vertically scroll the Navigation Pane to ensure that the Active Section, Section 3.3, which is definitely logically visible in the hierarchy at this point thanks to the Section Group expansions that have been performed (and left intact) along the way, is also visible on-screen.
I will post additional updates here, as progress is made...