evaluates all the evaluatable cells in notebook.

Details and Options

  • NotebookEvaluate returns the value returned by the last evaluation in the specified notebook.
  • NotebookEvaluate can take either a NotebookObject or a file name referencing a notebook file. If a file name references a notebook that is presently open, then evaluation proceeds on the open notebook.
  • The following options can be given:
  • InsertResultsFalsewhether to insert results in the notebook
    EvaluationElementsAllwhich cells to evaluate
  • By default, NotebookEvaluate displays the side effects of evaluation similarly to how a call to Get would. Messages, print output, and other side effects will be placed as output to the cell that called NotebookEvaluate rather than the specified notebook. Existing output cells in the notebook will not be updated or deleted.
  • NotebookEvaluate[notebook,InsertResults->True] handles side effects and outputs as if they would be handled in a TemplateBox[{shift, return}, Key1, BaseStyle -> {Notes, FontWeight -> Plain, FontFamily -> Source Sans Pro}] evaluation. Messages, print output, and other side effects are placed in the notebook along with outputs, and will replace any existing output or side effect cells.
  • When NotebookEvaluate[notebook,InsertResults->True] is used on a file that is not open, the Wolfram System will invisibly open the file, evaluate it entirely, save, and close the file.
  • NotebookEvaluate[notebook,InsertResults->False] will leave the notebook completely unmodified.
  • The cells of the notebook are evaluated in a dialog subsession.
  • Using NotebookEvaluate on an open notebook will cause the visible artifacts of subsession evaluation to occur in that notebook. The notebook will continue to be updated on screen as necessary while its cells are being evaluated.
  • Unlike Get, the presence of a syntax error in an evaluatable cell will not prevent NotebookEvaluate from evaluating other inputs.
  • NotebookEvaluate[notebook,EvaluationElements->Automatic] evaluates only the initialization cells. This is equivalent to saving the notebook as a package file, or with an automatically generated package file, and using Get on the resulting package file.
  • When run on a package file, NotebookEvaluate is equivalent to Get. The InsertResults option will be ignored.


open all close all

Basic Examples  (1)

Create a notebook:

Click for copyable input

Evaluate the notebook and return the result:

Click for copyable input

Generalizations & Extensions  (1)

Options  (3)

Applications  (1)

Properties & Relations  (2)

Possible Issues  (2)

Introduced in 2010