# Close all the generated cells in a cell group

I have tried to insert the AutoCollapse command defined in this nice answer

How to Keep Input Cells Hidden After Evaluating Notebook

inside a Button

  Button["Input Délétion OK",
AutoCollapse[] := (If[$FrontEnd =!=$Failed,
SelectionMove[EvaluationNotebook[], All, GeneratedCell];
FrontEndTokenExecute["SelectionCloseUnselectedCells"]])]
AutoCollapse[]


But AutoCollapse[] stay blue and unevaluated or is evaluated and then unevaluated --- MA 10.1. Any idea ?

• What are you trying to accomplish? Do want a button that can enable and perhaps disable the action of having AutoCollapse[ ] as the last evaluation item in a multi-expression input cell? Nov 15 '16 at 15:36
• Mainly, I want to hide the code, but I do not want to to it globaly but after verification of each input. Nov 15 '16 at 18:14
• AutoCollapse is not defined unless you click a button. And button itself does not evaluate AutoCollapse[] so I'm quite confused why it was left outside. Can you clarify?
– Kuba
Apr 13 '18 at 8:05