2
$\begingroup$

As suggested in this earlier post, I restate my question here about appending CellTags option to existing list of Cells.

What I have for the moment:

listOef = {};

SelectionMove[this, Before, Notebook];
SelectionMove[this, Next, Cell];
SelectionMove[this, Next, Cell];
Do[
 (
  SelectionMove[this, Next, CellGroup];
  AppendTo[listOef, NotebookRead[this]]
  )
  , {i, aantalVragen}]

This copies cells I give in the EvaluationNotebook[] to the list listOef.

I now want to write this list to the new notebook nb after permuting its elements randomly with

allPermutations = Table[RandomPermutation[aantalVragen], {aantalToetsen}];

like this:

 Do[
  (NotebookWrite[nb,
    Permute[listOef, allPermutations[[toetsNummer]]][[vraagNummer]]];
   ),
 {vraagNummer, aantalVragen}]

In this Do[] command, I would like to add Labels to every cell during the NotebookWrite command: its label would be "vraagNummer", the counter which goes from 1 to aantalVragen, which is given at the beginning of the document.

I'd like to have something like this:

SetOptions[ Cell, CellLabel->"vraag"<>ToString[vraagNummer] ]

but this doesn't seem to work. How can I address the cell which has just been written by NotebookWrite? Or how would you suggest to do this using this structure?

Thanks for all help!

$\endgroup$
2
$\begingroup$

I've found the answer for this question:

NotebookSelection[nb]

gives the selected region of notebook nb. So using

SetOptions[NotebookSelection[nb], 
  CellLabel -> "Vraag " <> ToString[vraagNummer] <> "."];

this can indeed change the CellLabel after writing the cell.

$\endgroup$

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.