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.

I have to close many cells each time before I export a notebook to HTML since I do not want to display many code cells and other cells.

I select each cell one by one, and do cell->cell properties->open to uncheck it, so it closes. Then I export to html. Then I have to go reverse the whole process one by one again. I do this many times during the day.

I am getting tired of doing this. I know in V9 there is now a cell API so I am sure there is a way to program this where one will add each cell into some cell group, and then issue a command to open or close all cells.

But, is there a way, from the notebook UI, a way to say to Mathematica: please select all closed cells. Then when they are selected, I can go use the UI to change the property of all selected cells at once using the cell->... as above. (I still have to select the cells again one by one when I want to close them again, but at least I can reduce the amount of work by half).

Actually, ideally what I'd like to do, is say: Export all cells except the Input and Code cells. i.e. selective Export by types of cells. That will be the most flexible way. i.e. there should be an export wizard, where one can select type of cells to export. So one can check in/off classes of cells in notebook, then click export. Default will be to export all cells.

thank you

share|improve this question
    
the short answer to all of this is yes. It is probably going to be easier in 9 but I don't have it yet. For the final part of your question just use NotebookGet to get the notebook expression and then DeleteCases with a pattern something like Cell[_,"Input"|"Code",___]. I'm about finished for tonight but if the question is still open tomorrow I will try a full answer. –  Mike Honeychurch Nov 30 '12 at 9:08
1  
This answer might probably help: mathematica.stackexchange.com/a/14470/5 –  rm -rf Nov 30 '12 at 14:41
add comment

1 Answer

up vote 3 down vote accepted

The link that @rm -rf provides does most of what you have asked for. For the final part of your question

Actually, ideally what I'd like to do, is say: Export all cells except the Input and Code cells. i.e. selective Export by types of cells.

Evaluate this code -- which you can modify for your particular circumstances -- in your notebook.

tmp = NotebookGet[EvaluationNotebook[]];
tmp = DeleteCases[tmp, Cell[_, "Input" | "Code", ___], \[Infinity]];
NotebookSave[tmp, "noimport.nb"]

Before:

enter image description here

After:

enter image description here

You will probably have to tweek it for your particular circumstances but that is the simple base code.

share|improve this answer
add comment

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.