# Opening a subgroup Explicitly vs Implicitly

Suppose we have a Section, Subsection and Subsubsection cell grouped automatically, as in the gif below. I can programmatically open the Subsection Cell using the code in the gif.

If the section cell is closed then the Subsection and subsubsection cells are not visible. However, when I apply the code, the cells open and are visible. This is what I mean by opening a group "explicitly". I do not want this.

Is it possible to open a group and that's all it does? I do not want to necessarily show it. I call this opening a group "implicitly". I know I can programmatically close the Section cell again. But I have many cell types and large notebooks, with many different levels of subgroups so this method is going to be a difficult puzzle. I'd like an easier method.

Is there some feature that allows me to open a subgroup (and not necessarily see it being opened)? It seems like this should be a feature as I'm asking for the bare minimum... just to open a group.

Since everything in Mathematica is an expression, all we need to do for these types of operations is to check the output of NotebookGet[InputNotebook[]] and see what replacements should be done.

For this problem you can try executing this:

NotebookPut[NotebookGet[InputNotebook[]] /.
CellGroupData[{Cell[x___, "Subsection", y___], z___}, Closed] :>
CellGroupData[{Cell[x, "Subsection", y], z}, Open],InputNotebook[]]

• Thank you, however this solution creates a new notebook with the feature requested. However, I need a solution that does this in the existing notebook. My notebook involve docked cells and hyperlinks... so its not going to work creating a new notebook. It seems like there must be a simple way. Ideas? – Michael McCain Oct 16 '16 at 7:12
• Fixed it. Now it overwrites the current one – dan7geo Oct 16 '16 at 7:14
• Thank you. hmmm... it seems to work... however, it's batting about 50% breaking Mathematica forcing me to restart. Strange. – Michael McCain Oct 16 '16 at 7:25
• If there is a way to do this without creating a new notebook it would help me a lot. However, if this is the only way... then I'll make do. Thank you. – Michael McCain Oct 16 '16 at 7:26
• Ideally you should do this in a different notebook and replace the InputNotebook[] with the path to the actual notebook. This might fix the problems – dan7geo Oct 16 '16 at 7:27