Onetastic Macro Documentation >
>
>
InsertObject InsertObject
Creates a new object and inserts it into OneNote hierarchy or into a OneNote page. Returns the newly created object. If you want to use an existing object to copy from, use CopyObject function.
Syntax
Object InsertObject(
Object parent,
ObjectType type,
Numeric position)
Parameters
- Object parent
- Parent object to create the new object under.
- ObjectType type
- The type of the new object to create and insert. See remarks for the types of objects that can be inserted.
- Numeric position
- The position of the new object. The value is a 0 based index for the child collection or -1 to insert at the end.
RemarksFollowing types of objects can be created, copied, and moved via InsertObject, CopyObject,
and MoveObject functions. See descriptions of each function for specific conditions or differences in behavior:
Parent Object |
Child Object Types |
Remarks |
Notebook |
SectionGroup Section |
Sections and section groups must have unique names inside a notebook. Section groups
cannot be copied or moved. Sections cannot be moved. |
SectionGroup |
SectionGroup Section |
Sections and section groups must have unique names inside a section group. Section groups
cannot be copied, moved, or removed. Sections cannot be moved or removed. |
Section |
Page |
|
Page |
Outline Image EmbeddedFile |
To create a Title object under a page, simply access its "title" property. |
Outline |
Paragraph Table Image EmbeddedFile |
An outline must have at least one child object. |
Paragraph |
Text Tag |
Text objects can only be inserted at the beginning or end of a paragraph. Text objects cannot be moved or removed |
Table |
Row |
A table must have at least one row. |
Row |
Cell |
A row must have at least one cell. Every row in a table must have the same number of cells. |
Cell |
Paragraph Table Image EmbeddedFile |
A cell must have at least one child object. |
Image |
Tag |
Image must be a direct child of a page to insert tags. Images inside outlines cannot have tags. Insert the tag into the image's parent paragraph instead. |
EmbeddedFile |
Tag |
Embedded file must be a direct child of a page to insert tags. Embedded files inside outlines cannot have tags. Insert the tag into the embedded file's parent paragraph instead. |
Examples
Copied!
$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"
|