({{, (RefLink[InitializationCell, paclet:ref/InitializationCell])
is an option for (RefLink[Cell, paclet:ref/Cell]) that specifies whether the cell should be tagged to be evaluated by the Wolfram Language kernel immediately before the first evaluation performed by the user after the notebook is opened. }})

OpenersNotesSection(Spacer1)Details

Additional front end options determine the precise behavior of initialization cells when a notebook is opened.

OpenersPrimaryExamplesSection(Spacer1)Examples  (1)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Create and save a notebook that has an input cell marked as initialization:

nb=CreateDocument[ExpressionCell[Defer[a=2+2],"Input",InitializationCell->True]];

temp=CreateTemporary[]<>".nb";
NotebookSave[nb,temp];NotebookClose[nb]

Initialization cells are useful when you reopen the saved notebook:

nb=NotebookOpen[temp];

You can use (MenuGrayLink[Evaluation, paclet:guide/EvaluationMenu]) ▶ (MenuGrayLink[Evaluate Initialization Cells, paclet:ref/menuitem/EvaluateInitializationCells]) to evaluate initialization cells:

Or, when you evaluate any cell, the Wolfram System asks if you want to evaluate the initialization cells:

If you choose Yes, initialization cells are evaluated:

Close the notebook and delete the temporary file:

NotebookClose[nb];
DeleteFile[temp];

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Evaluator, paclet:ref/Evaluator])  ▪  (RefLink[Initialization, paclet:ref/Initialization])  ▪  (RefLink[CellContext, paclet:ref/CellContext])  ▪  (RefLink[DockedCells, paclet:ref/DockedCells])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Options for Cells, paclet:tutorial/OptionsForCells])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Evaluation Options in Notebooks, paclet:guide/EvaluationOptionsInNotebooks])}})}})