Skip to main content
added 4 characters in body
Source Link
Sjoerd C. de Vries
  • 66.1k
  • 15
  • 189
  • 327

In version 9: suppose nb is your notebook object (this can be nb=EvaluationNotebook[]nb=EvaluationNotebook[], but if you're going to be closing input cells you probably want to have an auxilary notebook a choose the correct notebook from Notebooks[]Notebooks[]). Then, to close all the Input cells, for example, do

cells = Cells[nb, CellStyle->"Input"]
SetOptions[#, CellOpen -> False] & /@ cells

To open them back up

SetOptions[#, CellOpen -> True] & /@ cells

Obviously, you can select any style cell to close and open

In version 9: suppose nb is your notebook object (this can be nb=EvaluationNotebook[], but if you're going to be closing input cells you probably want to have an auxilary notebook a choose the correct notebook from Notebooks[]). Then, to close all the Input cells, for example, do

cells = Cells[nb, CellStyle->"Input"]
SetOptions[#, CellOpen -> False] & /@ cells

To open them back up

SetOptions[#, CellOpen -> True] & /@ cells

Obviously, you can select any style cell to close and open

In version 9: suppose nb is your notebook object (this can be nb=EvaluationNotebook[], but if you're going to be closing input cells you probably want to have an auxilary notebook a choose the correct notebook from Notebooks[]). Then, to close all the Input cells, for example, do

cells = Cells[nb, CellStyle->"Input"]
SetOptions[#, CellOpen -> False] & /@ cells

To open them back up

SetOptions[#, CellOpen -> True] & /@ cells

Obviously, you can select any style cell to close and open

Source Link
Itai Seggev
  • 14.3k
  • 61
  • 85

In version 9: suppose nb is your notebook object (this can be nb=EvaluationNotebook[], but if you're going to be closing input cells you probably want to have an auxilary notebook a choose the correct notebook from Notebooks[]). Then, to close all the Input cells, for example, do

cells = Cells[nb, CellStyle->"Input"]
SetOptions[#, CellOpen -> False] & /@ cells

To open them back up

SetOptions[#, CellOpen -> True] & /@ cells

Obviously, you can select any style cell to close and open