1
$\begingroup$

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

$\endgroup$
  • 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
2
$\begingroup$

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

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

(* ==> 2 *)

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

$\endgroup$

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.