Create Sections and Section Groups with Macros

June 27, 2017
Macros were able to create pages and page content which makes it very easy to generate lots of pages like the Diary Pages macro which creates a page for each day in a month or the Daily Manager Log macro which can create a page for each day in a whole year. However until now Macros didn't have the ability to create section group/section hierarchies, which are very important units of organization in larger notebooks.

With an update today, Onetastic Macros can now create new sections and section groups in notebooks and other section groups. This can be done with InsertObject function which is already used for creating pages and page content. The object type passed to the function can now be "Section" or "SectionGroup" and the parent object can be a notebook or a section group object.

Following is an example of creating a section group/section hierarchy in the current notebook. You can also download this sample macro here: Sample Create Section Hierarchy.

$notebook = GetCurrentNotebook() $SGDocs = InsertObject($notebook, "SectionGroup", -1) $ = "Macro Documentation" InsertObject($SGDocs, "Section", -1).name = "Getting Started" $SGFunctions = InsertObject($SGDocs, "SectionGroup", -1) $ = "Functions" InsertObject($SGFunctions, "Section", -1).name = "Array Functions" InsertObject($SGFunctions, "Section", -1).name = "DateTime Functions" InsertObject($SGFunctions, "Section", -1).name = "Dialog Box Functions" InsertObject($SGFunctions, "Section", -1).name = "Macro Execution Functions" InsertObject($SGFunctions, "Section", -1).name = "Object Functions" InsertObject($SGFunctions, "Section", -1).name = "String Functions" $SGOperators = InsertObject($SGDocs, "SectionGroup", -1) $ = "Operators" InsertObject($SGOperators, "Section", -1).name = "Arithmetic Operators" InsertObject($SGOperators, "Section", -1).name = "Assignment Operators" InsertObject($SGOperators, "Section", -1).name = "Comparison Operators" InsertObject($SGOperators, "Section", -1).name = "Logical Operators" InsertObject($SGOperators, "Section", -1).name = "String Concatenation Operator" InsertObject($SGOperators, "Section", -1).name = "Ternary Operator"

Macro Updates

Following macros in Macroland are updated:

Search & Replace

Added option to search in selected pages in the current section. Useful if you want to search and replace only in certain pages in the current section.

Extract highlighted Text

Added option to extract highlighted text in Current Section, Current Section Group, Current Notebook, and All Notebooks. The results are displayed in a new page (if the scope is not current page), grouped by section > page and links are provided for each of the highlighted text.

Sort Pages

Updated to sort numerically if page names start with numbers like 1, 2 etc. This correctly puts a section named 10... after sections named 1... through 9...

Search & Replace in Hyperlinks

Added option to do case insensitive search

Weekly Planner

Added option to pick Monday vs. Sunday as the first day of the week as well as ability to pick a range of weeks or a specific week in the future

New Macros

Several new macros have been added to Macroland since the last update. Check them out:

Sample Create Section Hierarchy

Creates a sample section group/section hierarchy

Proofing Language -> Swedish

Sets the proofing language on selected text to Swedish

Select Between First two Heading 1

Selects all content between the first and the second Heading 1 styled paragraphs in the current page

Format Numbers

Applies specific formatting to all numbers in the selection or the current page

Append Date to Title (

Modifies the page title to append the date in DD.MM.YY format


Omer Atay - 2017-07-14
Mikecharles261: No such feature at this point in Onetastic.

wone: Email for troubleshooting your installation.
wone - 2017-07-14
it doesn't work on my computer
it's windows 7 64bit using one note2016
it does not appear on the note after install
Mikecharles261 - 2017-07-12
Good morning. The ability to scan documents directly into oneNote is a very important part of our business productivity. I can't understate how important it is for our business to have this capability. I think Microsoft has made a big mistake by not incorporating this feature into the 2016 version of OneNote. The OfficeLens work-around is not acceptable. Has the Onetastic community invented a way to scan documents directly into OneNote 2016? Thank you. Bill

Other Posts

Show all posts