TOC in Current Page

Description : Creates a table of contents from heading in the current page and inserts at the top of the page. Optionally it adds "Back to Top" links to the headings.


Author(s) : Omer Atay
Category : TOC
Last Updated : December 07, 2020
Requirements : OneNote 2010 or above
Watch this short video to learn more about this macro
Screenshot :

TOC in Current Page

Include headings up to
Changelog :

December 07, 2020 (10CBCC) - Omer Atay
Added option to choose heading level for TOC

May 28, 2018 (CF836A) - Omer Atay
Fixed an issue where the macro will fail with an error

April 24, 2018 (1B3508) - Omer Atay
Fixed an issue where the "Back to Top" links wouldn't be updated if they already exist. Also the macro will now remember the "Back to Top" setting.

December 17, 2017 (EA5512) - Omer Atay
Updated to refresh the TOC in the current page if it already exists.

September 04, 2016 (157AED) - Omer Atay
Now finds all the headers in the page, even if they are in a table.

August 16, 2016 (C55DB0) - Omer Atay
Re-added the option for "Back to Top" links, which was lost in the previous update.

July 30, 2016 (A20BF1) - Omer Atay
TOC now uses indents based on heading level so that it can be collapsed

June 20, 2016 (E0E260) - Omer Atay
Re-written with the new Macro Language to take advantage of cleaner syntax and performance improvements

These versions are no longer supported:

July 24, 2014 - Omer Atay
Added the option for "Back to Top" links.

March 17, 2013 - Omer Atay
Initial version


Stan - 2021-06-25
After trying this out, I'm deleting it and never looking back. The glaring issue is that the creation of a new TOC messes up all the formatting beneath it, contrary to whatever carefully chosen/edited footage was shown in the introductory video. I created about 7 TOCs before realizing this, so I have had to go back and revert all changes in order to preserve the formatting of my notebook.

Would be useful if not for this terrible problem.
Lars - 2020-12-06
Is there a way to only choose to make a TOC of the main header in a page?
Neman - 2020-11-23
A possible font colour fix as per Omer that worked for me on my version of OneNote 2016 16.0.13328.20350, oddly named "Version 2010" and "OneNote for Microsoft 365":
This is a bug in OneNote. They fixed it in a newer version. Depending on what version you have, you might be able to switch to that new version by setting a registry key (see below). The alternative to that is to wait until the new build is deployed or don’t use light text colors in tables.
Registry key to create:
                Name: OverrideVersion
                Type: REG_DWORD
                Value: 1
Obviously you take your life into your hands when editing the Registry. Back up everything - EVERYTHING - make your will, etc. and don't do any of these things to be safest.
Show more comments (100 more)