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