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


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.
Neman - 2020-11-09
+1 to comment from Gab Loranger (2019-02-13)
I have tables on my page where the header font is bold and white. Every single time I run TOC in Current Page, the header font changes from white to grey. No exception.

So far, this doesn't seem to affect any other text on my page, but it's all default-coloured, i.e. text is black, headings are bley, and so forth.