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


evaluates all the evaluatable cells in notebook.
  • 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 evaluates the cells of a notebook in the same way that Get evaluates the lines of a package file. 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] evaluates the notebook as if all cells had been evaluated with Shift+Enter. Messages, print output, and other side effects are placed in the notebook along with outputs.
  • When NotebookEvaluate[notebook, InsertResults->True] is used on a file that is not open, Mathematica will invisibly open the file, evaluate it entirely, save, and close the file.
  • 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.
Create a notebook:
Evaluate the notebook and return the result:
Create a notebook:
Click for copyable input
Evaluate the notebook and return the result:
Click for copyable input
Insert results in the target notebook:
By default, messages go into the output:
With InsertResults->True, the messages go to the target notebook instead:
Evaluate only initialization cells in a notebook:
works in notebooks targeted by NotebookEvaluate:
Notebooks evaluate in their default context, which may be different from the context used by NotebookEvaluate:
If the contexts need to be the same, it may be necessary to set the CellContext option of the notebook:
Evaluation history is scoped to the notebook being evaluated:
New in 8