6

The following creates a button to select a notebook to run. When the button is pressed it seems that Mathematica finds the notebook but cannot evaluate it. The following error occurs

Could not process unknown packet "1"

Button["run file 1", 
     NotebookEvaluate[
      "/../file1.nb"]]

This occurs under Mathematica 8 on all platforms.

Any help greatly appreciated, Christina

Christina
  • 199
  • 9

2 Answers2

7

To make it work, use

Button["run file 1", NotebookEvaluate["/../file1.nb"], Method->"Queued"]
celtschk
  • 19,133
  • 1
  • 51
  • 106
4

In the comments celtschk suggested Button[..., Method -> "Queued"] and Christina confirmed it as a solution.

Mr.Wizard
  • 271,378
  • 34
  • 587
  • 1,371
  • 1
    @Christina does Button["run 1", NotebookEvaluate["/../file1.nb"]] also work by itself? – Mr.Wizard May 22 '12 at 16:50
  • 1
    Great question @Mr.Wizard. It doesn't, I get the same error, so my question should actually be "How do I make NotebookEvaluate work inside Button?" I can't believe I didn't test that. – Christina May 22 '12 at 16:56