Onetastic Macro Documentation >
>
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:
$Page = InsertObject(GetCurrentNotebook().sections[0], "Page", -1)
$Page = GetCurrentPage()
$Outline = InsertObject($Page, "Outline", -1)
$Paragraph = InsertObject($Outline, "Paragraph", 0)
$Paragraph.text = "Below is 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
InsertObject($Paragraph, "Text", -1).value = " cell"
InsertObject($Row, "Cell", -1).text = "A second cell"
Following is the list of objects macros recognize with the hierarchical structure:
Notebook
│
├─ Section
│ │
│ └─ Page
│
└─ SectionGroup
│
└─ ·····
│
└─ SectionGroup
│
└─ Section
│
└─ Page
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
│
└─ ·····
|