Tutorial

Getting Started with Macros

Macro Editor

User Interface

Menus and Toolbar

Editing Macros

Macro Debugging

How To

Using variables

Finding and modifying objects

Creating new page content

Asking for user input

Storing persistent data

Using binary data

Sorting objects

Macro menus

Bulleted and numbered lists

Sample Macros

Concepts

Expressions

Objects

Properties

Variables

Data Types

Arrays

Functions

Literals

Operators

Comments

Last updated on: September 02, 2024
Also available as a single HTML file

Onetastic Macro Documentation > Concepts > Objects

Objects

Objects in macros represent OneNote's notebook/section/page hierarchy as well as the contents of a OneNote page.

Querying Objects

Macros can query objects using QueryObjects function and modify their properties:

foreach ($Text in QueryObjects("Text", GetCurrentPage())) If($Text.highlightColor == "yellow") $Text.highlightColor = "green"

Macros can also create new pages and insert content on a page:

// Create a page at the end of the first section of the current notebook $Page = InsertObject(GetCurrentNotebook().sections[0], "Page", -1) // Create an Outline and a Paragraph $Page = GetCurrentPage() $Outline = InsertObject($Page, "Outline", -1) $Paragraph = InsertObject($Outline, "Paragraph", 0) $Paragraph.text = "Below is a table" // Now create a table $Table = InsertObject($Outline, "Table", -1) $Row = InsertObject($Table, "Row", -1) $Cell = InsertObject($Row, "Cell", -1) $Paragraph = InsertObject($Cell, "Paragraph", -1) $Text = InsertObject($Paragraph, "Text", -1) $Text.value = "First" $Text.bold = true // Add More text in this paragraph InsertObject($Paragraph, "Text", -1).value = " cell" // Add more cells InsertObject($Row, "Cell", -1).text = "A second cell"

Following is the list of objects macros recognize with the hierarchical structure:

Hierarchy Objects

Notebook
  │
  ├─ Section
  │    │
  │    └─ Page
  │
  └─ SectionGroup
       │
       └─ ·····
            │
            └─ SectionGroup
                 │
                 └─ Section
                      │
                      └─ Page

Page Objects

Page
  │
  ├─ Image
  │    │
  │    └─ Tag
  │
  ├─ EmbeddedFile
  │    │
  │    └─ Tag
  │
  ├─ Title
  │    │
  │    └─ Paragraph
  │            │
  │            ├─ Tag
  │            │
  │            └─ Text
  │
  └─ Outline
       │
       └─ Paragraph
            │
            ├─ Tag
            │
            ├─ Text
            │
            ├─ Image
            │
            ├─ EmbeddedFile
            │
            └─ Table
                 │
                 ├─ Column
                 │
                 └─ Row
                      │
                      └─ Cell
                           │
                           └─ Paragraph
                                │
                                ├─ Tag
                                │
                                ├─ Text
                                │
                                ├─ Image
                                │
                                ├─ EmbeddedFile
                                │
                                └─ Table
                                     │
                                     └─ ·····

Reference

Statements

Hierarchy Objects

Page Objects

Other Objects

Functions

Array Functions

Color Functions

Data Store Functions

Date/Time Functions

Dialog Box Functions

Macro Execution Functions

Macro Menu Functions

Object Functions

Special Functions

String Functions

Window Functions