This is documentation for Mathematica 8, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.1)

NotebookWrite

NotebookWrite
writes data into a notebook at the current selection, setting the current selection to be just after the data written.
NotebookWrite
writes data into a notebook, setting the current selection to be as specified by sel.
  • NotebookWrite does essentially the same as a Paste operation in the front end: it replaces whatever the current selection in the notebook is by data.
  • NotebookWrite is the basic way to use the Mathematica kernel to modify the contents of notebooks that are being manipulated by the front end.
  • NotebookWrite automatically wraps Cell around the data you specify if this is necessary.
  • Possible settings for sel are:
Afterplace the current selection immediately after the data written
Allmake the current selection be the data written
Beforeplace the current selection immediately before the data written
Noneleave the current selection unchanged
Placeholdermake the current selection be the first placeholder in the data written
  • The default for sel is , so that NotebookWrite can be called repeatedly to insert several pieces of data in sequence.
Create an empty notebook and write a cell:
Write another cell and select it:
Create an empty notebook and write a cell:
In[1]:=
Click for copyable input
Write another cell and select it:
First create an empty sample notebook to operate on:
Write a tall cell expression to the sample notebook and the scroll position remains at the top:
Use NotebookWrite to write over a selected part of the document:
Or use NotebookPut to replace the full contents:
New in 3