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

The Evaluate > EvaluateNotebook evaluates the whole notebook.

Is it possible to somehow evaluate ONLY the open sections of a notebook?

share|improve this question

This will only work if you have all open cells also grouped. Generate, for example

Cell[CellGroupData[{Cell["test3", "Section"], Cell[BoxData[\(3 - 3\)], 
              "Input"]}, Open]]}] // NotebookPut

Then, generate a palette like this:

CreatePalette[Button["Eval Open", 
   Module[{r, n = SelectedNotebook[]}, 
    SelectionMove[n, Before, Notebook]; 
     While[SelectionMove[n, Next, CellGroup]; 
       r = NotebookRead[n]; MatchQ[r, 
        Cell[CellGroupData[_, _]]], 
      If[MatchQ[r, Cell[CellGroupData[__, Open]]], 
       Print["nu"]; SelectionEvaluate[n]]]]]]

Then, click on the first notebook. Subsequently click on the button and be surprised.

share|improve this answer

Your Answer

 
discard

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

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