10
$\begingroup$

Is there a way to "lock" some cells in a notebook so they can't be edited? It's usually input cell that's documenting some functionality. I'd like other readers of the notebook to be able to execute them but not changing them.

$\endgroup$
2
  • 3
    $\begingroup$ You've seen Editable already? $\endgroup$ Oct 31, 2012 at 16:39
  • $\begingroup$ How to resolve it? Can it be resolved without being deleted? $\endgroup$
    – qazwsx
    Oct 31, 2012 at 19:33

2 Answers 2

10
$\begingroup$

If you want to make some cell non editable, mark these cells and use the menu entry

Cell -> CellProperties

and remove the mark before Editable.

If your cell is an Input-Cell, it can be evaluated but not edited.

$\endgroup$
3
  • 2
    $\begingroup$ For extra protection, before making the cell not Editable, you may wish to make it not Deletable. To do so, select the cell, open the Option Inspector, and uncheck Deletable in the Cell Options > General Properties section. (And while you're there you can then also uncheck Editable.) $\endgroup$
    – murray
    Nov 1, 2012 at 20:30
  • $\begingroup$ @murray, nice tip. I wasn't aware of the Deletable option. $\endgroup$ Nov 2, 2012 at 9:38
  • $\begingroup$ And as I learned when I first tried it, you must make a cell non-Deletable before you make it non-Editable! $\endgroup$
    – murray
    Nov 2, 2012 at 13:45
9
$\begingroup$

Suppose you have an open notebook, say "Untitled-1". The following code, executed in the same notebook or another, will select all the Input cells and set them to un-Editable and un-Evaluatable.

nb = First[Notebooks["Untitled-1"]];
inputCells = NotebookFind[nb,
  "Input", All, CellStyle];
SetOptions[inputCells, 
  Evaluatable -> False,
  Editable -> False]
$\endgroup$
0

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.