Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wanting to run about 15 pages of initialization cells in a CDF, but can't seem to do so. I have set the InitializationCellEvaluation to True and InitializationCellWarning to False, but it doesn't work in the CDF. (works just fine in the .nb) I saw something about the NotebookDynamicExpression, but I wasn't sure how to run a ton of code through it.

Are there any alternatives? I use no Manipulate or Dynamic functions in my code either. For example...

GenerateDisplayShotsFor := 
    Style["GENERATE", Bold, FontFamily -> "Terminal", 20, 
     Background -> LightBlue], 
     DocumentNotebook[DisplayShotsFor, WindowTitle -> "Shots For", 
      WindowFrame -> "ModelessDialog", 
      Background -> RGBColor[48/240, 164/240, 220/240], 
      Editable -> False, TextAlignment -> Center , 
      WindowFloating -> False, 
      WindowMargins -> {{0, Automatic}, {Automatic, 0}}]]]];
share|improve this question
If I'm not mistaken it is not going to work.You have to put those definitions inside Initialization in DynamicModule or use SaveDefinitions for Manipulate. – Kuba Jul 26 '13 at 18:40

It's probably a good idea to look at this question more more information about writing CDF-happy notebooks. In brief, Initialization cells won't function properly in the CDF format. For example if we have the following initialization cell:

a = 1;

And subsequent cell that is not an initialization cell

Manipulate[b + x, {x, 1, 10, 1}]
Manipulate[a + x, {x, 1, 10, 1}, Initialization :> (a = 1;)]

The first Manipulate will not evaluate b when exported in CDF format. All of your initialization needs to go in the Initialization option of Manipulate in this case. As mentioned in the question references above, this seems to be the easiest way to get initialization into a CDF, even if Manipulate is not being used.

share|improve this answer
Thank you, but my initialization cells are buttons, graphs, images, and functions being defined that wait for user inputted values. Does Manipulate still work on them? I haven't figured how to wrap them. – user8736 Jul 26 '13 at 19:40
@user8736 You might be asking a bit much out of CDFs. This answer has some insight into managing code for CDFs. – bobthechemist Jul 26 '13 at 20:53
Okay. I understand. Thank you for the link. If you know of another way to deploy a secured (unable to view code etc) notebook feel free to say so. Again, thanks for your help. – user8736 Jul 26 '13 at 21:07

Your Answer


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.