I have a very simple problem with Mathematica that I couldn't find an easy answer to. I have long notebook with a lot of cells and want to evaluate a specific cells inline from another cell.
So far I have been trying to put tags on the cells and then use: NotebookEvaluate[EvaluationNotebook[], EvaluationElements -> "Tags" -> {tag1, tag2,..}]
I thought that this should do it, but instead it always evaluates the whole notebook and gets stuck in a loop. Is there something slightly wrong, or a trick with the tag names? Or am I doing something conceptually wrong?
Btw it works fine if I use the option EvaluationElements-> "InitializationCell" but doesn't work properly with the "Tags" option.
Answer
Assuming you are doing this in the same notebook then:
nb = EvaluationNotebook[];
NotebookFind[nb, "tag1", All, CellTags]
SelectionEvaluate[nb]
If you have several tagged cells that you want to evaluate then
(NotebookFind[nb, #, All, CellTags];SelectionEvaluate[nb]) & /@ {"tag1", "tag2"}
Edit
The above is the way I would normally do it because it predates the addition of EvaluationElements
. I tried that method and it failed in V9. Additionally the example in the docs fails (V9 OS X) which seems a good enough reason to call this a V9 bug.
Contrary to earlier edit this is now working in V10.
Comments
Post a Comment