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.

Download

Author(s) : Onetastic
Category : TOC
Last Updated : August 08, 2022
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 :

August 08, 2022 (EFAC69) - Onetastic
Fixed an issue where the macro will fail with an error on some pages with images

May 14, 2022 (9F1898) - Onetastic
Fixed a bug where page content would be removed if it consists of tables or other non-text content

January 17, 2022 (EE2A63) - Onetastic
Added option to have the TOC contain list numbers if the headings are part of a numbered list.

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

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

April 24, 2018 (1B3508) - Onetastic
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) - Onetastic
Updated to refresh the TOC in the current page if it already exists.

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

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

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

June 20, 2016 (E0E260) - Onetastic
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 - Onetastic
Added the option for "Back to Top" links.

March 17, 2013 - Onetastic
Initial version

Comments

Name
Comment
Dan Beckvall - 2022-02-17
Is there a way to install these Macros without the Onetastic addon?  PC policies don't let me install the addon but I can make my own macro and paste in the code.
stachu99 - 2022-01-23
Thanks Omer for the last update (January 17, 2022).
stachu99 - 2022-01-15
Hi Omer
Could you consider to add new fuctionality to your macro?
I  would be happy if you add a paragraph number if the paragraph belongs to the number list.

Add code
   DialogBox_AddCheckBox($dialogBox, "Add &list number", "list", $defaultValues[false])
   $list = $dialogBox.controls["list"]
and replace
   $Text = InsertObject($Inserted_Paragraph, "Text", -1)
   $value = $Paragraph.text
with
   $Text = InsertObject($Inserted_Paragraph, "Text", -1)
   if ($list && $Paragraph.isPartOfNumberedList)
      $value = $Paragraph.numberText + " " + $Paragraph.text
   else
      $value = $Paragraph.text

Show more comments (103 more)