Having opened and executed a notebook using NotebookOpen and NotebookEvaluate, I want to return the EvaluationNotebook to the foreground

  • 1
    $\begingroup$ Ctrl-Tab (OSX: CMD-Tilde)? $\endgroup$ – march Nov 10 '15 at 19:29
  • 1
    $\begingroup$ Ctrl+F6 on windows $\endgroup$ – Coolwater Nov 10 '15 at 19:45

I think what you're asking for is something like this:

nb0 = EvaluationNotebook[]; nb = 
  ExpressionCell[Defer[Plot[Sin[x], {x, 0, 2 Pi}]], "Input"]];
NotebookEvaluate[nb, InsertResults -> True];
1 + 1

(* ==> 2 *)

This uses SetSelectedNotebook to restore the initially saved nb0 as the current notebook after evaluating the new notebook nb.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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