Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wondering what exactly are the differences in using

NotebookEvaluate[filename] vs FrontEndExecute[FrontEndToken[nb, "EvaluateInitialization"]];

to evaluate cells in a given notebook.

In particular, I am referring to the discussion: Evaluate Initialization Cells of another notebook. Given my new status here, I couldn't see how I could continue with that conversation directly, so I decided to post a new queston.

The comments in the referenced question proposed these two solutions to the problem:

  • method 1.

    filename = SystemDialogInput["FileOpen"];
    NotebookEvaluate[filename, EvaluationElements -> "InitializationCell"]
  • method 2.

    filename = SystemDialogInput["FileOpen"];
    nb = NotebookOpen[filename];
    FrontEndExecute[FrontEndToken[nb, "EvaluateInitialization"]];

I am trying to solve the same problem. Taken at face value, it seems both approaches are valid. Are there any subtleties that make one preferred to the other, issues of scope/context, etc.?

share|improve this question
Have you tried consulting the documentation centre ? – Sektor Jan 20 '14 at 11:39
Yes, and from that documentation I see no difference. i.e. two different ways to achieve the same end result. I was confused by the discussion between @AlexeyPopkov and Jacob which I took to suggest there is a difference between the two methods with regards to what happens in the FrontEnd vs kernel. – tbtom Jan 20 '14 at 15:22
NotebookEvaluate returns the last expression evaluated. Also, to make them more comparable you may have to add NotebookOpen[..., Visible->False] – Rojo Jan 20 '14 at 22:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.