I can select the first cell like this:
nb = CreateDocument[{a, b, c}, WindowTitle -> "Other"];
SelectionMove[nb, Next, Cell]
But how to select the first and the second cell?
I can select the first cell like this:
nb = CreateDocument[{a, b, c}, WindowTitle -> "Other"];
SelectionMove[nb, Next, Cell]
But how to select the first and the second cell?
Ah, now I recall why I emphasized "non adjacent" in Programmatically selecting non adjacent Cells
It is because you can select adjacent cells by mimicking what FE does when you use keyboard shortcuts:
Item[KeyEvent["Down", Modifiers -> {Shift}], "SelectNextLine"],
-KeyEventTranslations.tr
So in our case:
Select the first cell for a set you want to select
Repeat token execution
SelectionMove[First @ Cells[], All, Cell]
FrontEndExecute @ FrontEndToken["SelectNextLine"]
You could create the Notebook with tags and later evaluate those. Notebooklocate also works with stored notebooks. Consider that the Cells maybe only are evaluateable if the type is set to "Input".
nb1 = CreateDocument[{Cell["a=2", "Input", CellTags -> "myTag"],
Cell["b"], Cell["c=3d", "Input", CellTags -> "myTag"]},
WindowTitle -> "myCreation"]
SetSelectedNotebook[nb1]
NotebookLocate["myTag"]
SelectionEvaluate[nb1]