Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.