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)
$SGDocs.name = "Macro Documentation"
InsertObject($SGDocs, "Section", -1).name = "Getting Started"
$SGFunctions = InsertObject($SGDocs, "SectionGroup", -1)
$SGFunctions.name = "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)
$SGOperators.name = "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:
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.
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.
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...
Added option to do case insensitive search
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:
Creates a sample section group/section hierarchy
Sets the proofing language on selected text to Swedish
Selects all content between the first and the second Heading 1 styled paragraphs in the current page
Applies specific formatting to all numbers in the selection or the current page
Modifies the page title to append the date in DD.MM.YY format
Comments