I have two Notebooks and I call the second Notebook from the main but main Notebook's expressions continue executing. I want them to wait until the second Notebook's expressions execution is finished!

My main Notebook's code is such as:

docpath = ToFileName[{"C:", "Users"}, "MATHEMATICA"];

nbLBDxi = NotebookOpen[ToFileName[docpath, "LBDxi.nb"]];

SelectionMove[nbLBDxi, All, Notebook];


  • Here the main Notebook's other expressions, which I won't write for brevity, will come but I want them to wait until the above expressions' execution is over.

1 Answer 1


Probably you should use NotebookEvaluate instead of SelectionEvaluate. According to the Documentation,

By default, NotebookEvaluate evaluates the cells of a notebook in the same way that Get evaluates the lines of a package file.

For example try:

nb = CreateDocument[ExpressionCell[Defer[Pause[10]], "Input"]];

The Print["!"] statement is evaluated only when evaluation of the Notebook nb is finished!

  • $\begingroup$ Thank you @Alexey Popkov your reccomendation, using NotebookEvaluate instead of SelectionEvaluate, solved the problem. $\endgroup$
    – ahmethasim
    Commented Jun 27, 2016 at 12:09
  • $\begingroup$ @ahmethasim Then you can Accept my answer by clicking the green checkmark. $\endgroup$ Commented Jun 27, 2016 at 12:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.