Onenote, Tutorial

Replacing Hyper Links

Ever run into an issue where you copy a page from one notebook, and the links still try to point to the original one? Here’s a quick method for updating hyperlinks (Desktop version only).

First, you’ll want to right click on an existing Hyperlink and choose Edit Link.

Here is an example of what the “CT: Combat Tracker” text link to:

onenote:..\DM%20Tools.one#CT%20Combat%20Tracker&section-id={C775FB2B-D433-417E-B089-5EF29CAACFA0}&page-id={2DB82156-E612-44D6-9365-4770C7356104}&end&base-path=https://d.docs.live.net/8ef41446453a2105/Documents/Adventure%20Academy/SRD%20Reference

You can see Onenote uses a somewhat complicated string to tell itself where to look for a page in case that it can’t immediately locate the page (or in case it finds several identically named pages). A quick breakdown of the address reveals that it is first telling the program to look inside Onenote (as opposed to a web link), then to jump up one level in the notebook’s hierarchy and look inside the”DM Tools” section instead for the “CT Combat Tracker” page name. Beyond that it gets even more in depth with a specific section id, page id, and a base path that directs it to a specific notebook.

This last portion is what causes the most headaches for users who copy tabs from the shared notebook into their own, as the super specific nature of that hyperlink will always try to open the page from the shared notebook rather than the local one even when their notebook structure is identical. If you close the shared notebook (and then remove it from the list of notebooks), that might be enough to force Onenote to ignore the later part of the link. Otherwise, you might have to trim the ending off of the link so that Onenote will only look for the page locally. In this case, we really only need the link to point to:

onenote:..\DM%20Tools.one#CT%20Combat%20Tracker

Onetastic Macros: A Life Saver

This is easy enough to do by simply selecting and deleting anything that comes after it, but this task becomes a bit more daunting (and monotonous) when you’re looking at replacing hundreds if not thousands of instances of the link. Thankfully Onetastic can save the day, as a macro can replace these links for us.

Onetastic Macro: Search and Replace in Hyperlinks

XML Encoding

First, a note of importance with this macro. It works by examining and editing the .xml of the page, which encodes characters in the hyperlinks a bit differently than how Onenote displays them. For example, here is the xml for that same link, in red:

As you can see from the highlights, the xml replaces all instances of the the ampersand with a longer 5-character reference code for it, so when using the macro to alter hyperlinks we’ll need to make sure we use this longer form too.

Example: this is what it would look like instead of just &section-id=

So here I’d just paste in the specific part of the hyperlink that I want to find and remove (anything that comes after Onenote:..\DM%20Tools.one#CT%20Combat%20Tracker ), and update the four instances of the ampersand so that the macro will actually be able to find it in the .xml

You don’t need to enter any text into the Replace field, leaving it blank will essentially just erase it leaving us with the shortened local link only. I’d probably play it safe and do this on a smaller scope, one Section at a time and one link type at a time. You can test on a single page first.

Leave a Reply

Your email address will not be published. Required fields are marked *