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

Copying and moving objects

Asking for user input

Storing persistent data

Using binary data

Sorting objects

Macro menus

Bulleted and numbered lists

Accessing the file system

Accessing the clipboard

Sample Macros

Concepts

Expressions

Objects

Properties

Variables

Data Types

Arrays

Functions

Literals

Operators

Comments

Last updated on: June 21, 2025
Also available as a single HTML file

Onetastic Macro Documentation > How To > Accessing the clipboard

Accessing the clipboard

With macros, you can read from and write to system clipboard and access any plain text, HTML or image content in the clipboard. This can allow you to copy content from OneNote in various formats as well as paste content into OneNote programmatically. Following functions facilitate these:

  • Clipboard_Get
    Returns information from the clipboard for the specified format.
  • Clipboard_Set
    Puts information into the clipboard.
  • Clipboard_Query
    Returns whether the clipboard contains the specified format or not.

HTML Objects

Applications often use HTML as the format for transferring rich content through Clipboard or other mediums. To help with this you can now export content from OneNote into HTML format as well as import HTML content into OneNote. See details of following function and object type for more information:
  • GetFormattedObjectContent
    Returns the contents of an object in either plain text or HTML format. This can be useful to put the content into clipboard using Clipboard_Set, or process it further.
  • HtmlBlock
    An object type that represents a block of HTML to be inserted into a OneNote Outline or Cell.

Examples

Clipboard_Set and GetFormattedObjectContent
Copied!
// Put some text into clipboard Clipboard_Set("plain", "Some text") // Put some HTML into clipboard. This replaces the previous plain text. Clipboard_Set("html", "Some <b>Text</b>") // Put both plain text and HTML into clipboard Clipboard_Set(Array("plain", "html"), Array("Some text", "Some <b>Text</b>")) // Put contents of an outline as HTML into clipboard $outline = GetCurrentPage().outlines[0] Clipboard_Set("html", GetFormattedObjectContent($outline, "html")) // Put contents of an image into clipboard $image = GetCurrentPage().images[0] Clipboard_Set("image", $image.data)
Clipboard_Query, Clipboard_Get, and HtmlBlock
Copied!
// Get some text from the clipboard and insert into the current page title $page = GetCurrentPage() if (Clipboard_Query("plain")) $page.title.paragraph.text = Clipboard_Get("plain") // Get some HTML from the clipboard and insert into the current page if (Clipboard_Query("html")) $htmlBlock = InsertObject($page.outlines[0], "HtmlBlock", -1) $htmlBlock.value = Clipboard_Get("html") // Get some image from the clipboard and insert into the current page if (Clipboard_Query("image")) $image = InsertObject($page, "Image", -1) $image.data = Clipboard_Get("image")

Reference

Statements

Hierarchy Objects

Page Objects

Other Objects

Functions

Array Functions

Clipboard Functions

Data Store Functions

Data Type Specific Functions

Date/Time Functions

Dialog Box Functions

File System Functions

Macro Execution Functions

Macro Menu Functions

Object Functions

Special Functions

String Functions

Window Functions