# Write Printed Cells To File

Is there a way to write printed out cells to a file easily?

NotebookFind[nb = EvaluationNotebook[], "Print", All, CellStyle];


This selects them but I would like to then write to a file.

• Would it be possible for you to write them to a file when they're printed rather than after the fact? This would make it a lot easier, I think – user6014 Oct 29 '16 at 17:47
• So for example, instead of Do[Print[x^2];, {x, 1, 10}], something like Do[Print[x^2]; Write[file, x^2];, {x, 1, 10}], which will print AND be writing the content to file as well. I don't know the scope of your project, but this could be easier and more efficient. – user6014 Oct 29 '16 at 18:45

temp = CreateDocument[{}, WindowSelected -> False];