|
Onetastic Macro Documentation >
>
Finding and modifying objects
Finding and modifying objects
Macros typically work by finding objects in OneNote and modifying their properties. There are that provide direct access to notebooks, sections and pages in OneNote as well as provide ability to search through them. Following macro demonstrates these functions:
Copied!
$CurrentPage = GetCurrentPage()
$CurrentSection = GetCurrentSection()
$CurrentSectionGroup = GetCurrentSectionGroup()
$CurrentNotebook = GetCurrentNotebook()
$NotebookRoot = GetNotebookRoot()
$Images = QueryObjects("Image", $CurrentPage)
$AllInstancesOfTheWordOnetastic = QueryText($CurrentPage, "Onetastic", true)
$AllInstancesOfTheWordOnetastic = QueryText($CurrentPage, "Onetastic", false)
$FirstOnetastic = $AllInstancesOfTheWordOnetastic[0]
if (GetParentOfType($FirstOnetastic, "Paragraph", $ParentParagraph))
if (GetAncestorOfType($FirstOnetastic, "Notebook", $ContainingNotebook))
Accessing object properties
To read or modify properties of objects, you can use the property accessor (.).
Copied!
$Name = GetCurrentPage().name
$CurrentSection = GetCurrentSection()
$CurrentSection.name = "new name"
$CurrentSection.color = "yellow"
$Section = GetNotebookRoot().notebooks[0].sections[1]
|