# How can I update the contents of or overwite a cell contained inside another cell?

Suppose I have a notebook consisting of these cells:

• Cell G, containing a grid
• Cell I, containing a program that produces a graphic and places it in a cell
• Cell E, a cell which successfully receives the graphic from cell I

One of the items in the grid in Cell G contains Cell D, which is where I'm trying to place my graphic.

The program in Cell I successfully places the graphic it creates by using this technique:

graphic=ToBoxes[Graphics[graphics]];

cell=Cell[StandardForm[graphic],CellTags->"cell-E"];

NotebookWrite[First[Cells[CellTags->"cell-E"]],cell];


So far, this is awesome. My program does not generate any output cells, but I can [Shift]-[Enter] it and see the graphic appear in Cell E wherever that happens to be.

But what I need is for the graphic to appear in Cell D. Currently, I'm trying to use this simple extension to the original idea:

NotebookWrite[First[Cells[First[Cells[CellTags->"cell-D"]], CellTags->"cell-G"]],cell];


But alas, I get a beep:

You tried to edit inside a subexpression that cannot be edited, because it is a fixed special form.

Several hours of googling and experimenting have not yielded fruit. And, in particular, I have been unable to find out what is meant by "fixed special form".

I have discovered only the following:

• The problem isn't whether the cell is editable.
• The problem isn't the grid.
• The problem isn't how I'm trying to get to Cell D. That is, my code does return the correct CellObject.

Anybody know anything?

Got it at last. Turns out it all came down to how Cell D was being created in the first place, which was like this:

Grid[{{TextCell["Test2",CellTags->{"Cell-D"}],"Stuff","Stuff"}}]


Looks perfectly innocuous, but it doesn't actually spit that out. When I evaluated that, the expression that was actually produced was this:

Cell[BoxData[
TagBox[GridBox[{
{
InterpretationBox[Cell["Cell D",
CellTags->{"cell-d"}],
TextCell["Cell D", CellTags -> {"cell-D"}]], "\<\"+\"\>", "\<\"Hello\"\>"}
},
AutoDelete->False,
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
"Grid"]], "Output",
CellChangeTimes->{3.650519194416835*^9, 3.6505192328698063*^9, 3.650519265619585*^9, {3.650519309424439*^9, 3.650519327862068*^9}, 3.65051936737801*^9, 3.650519575017583*^9,
3.6505198091531763*^9}]


The problem here is the InterpretationBox. I do not know for sure, but I believe that's what Mathematica was talking about when it said "fixed special form". And it looks pointless, too. All it does is take my TextCell and present it as a plain Cell.

Thing is, using a plain Cell was the very first thing I tried, and it didn't work like you would expect:

In[212]:= Cell["Cell D",CellTags->{"cell-D"}]
Out[212]= Cell[Cell D,CellTags->{cell-D}]


I don't know why Mathematica does this, but the way around it was to wrap my cell in DisplayForm[], which is intended specifically to address this issue. With my plain cell printing as I expect it to, I can use it my grid, and now I don't have an InterpretationBox, and now my code works like I expect!