3
$\begingroup$

I have a subsubsection cell, inside a subsection cell, inside a section cell. Assuming all groups and subgroups are closed so that only the section cell is visible, is it possible to programmatically change the state of the subsection cell to "open" without the section cell opening?

NotebookFind (as shown below) is no use because it opens the parent cell.

NotebookFind[EvaluationNotebook[], "Subsection", All, CellStyle];
FrontEndExecute[FrontEndToken["OpenCloseGroup"]]

I'm thinking there must be a way to change the open/close state of a cell that is hidden behind a closed parent cell.

$\endgroup$
1
$\begingroup$

A standard approach with SelectionMove seems to work:

(
   SelectionMove[#, All, Cell];
   FrontEndExecute[FrontEndToken["OpenCloseGroup"]]
) & /@ Cells[CellStyle -> "Subsection"];
$\endgroup$
  • $\begingroup$ Great answer! Thank you. Follow up... How could I alter this code so that it will work from an external palette? I've been messing around with it but my knowledge of "cell objects" is minimal and fuzzy. Somehow I've managed to get by without learning them... but I'm determine to learn. $\endgroup$ – Michael McCain Nov 28 '16 at 9:27
  • 1
    $\begingroup$ @MichaelMcCain You need to add InputNotebook[] specification to Cells and probably to FrontEndToken too. Tell me how it went :) $\endgroup$ – Kuba Nov 28 '16 at 9:28
  • $\begingroup$ Yes. That worked. Once again... I forgot to specify InputNotebook[] on a question here. Thanks again! $\endgroup$ – Michael McCain Nov 28 '16 at 9:38

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.