Skip to main content
added 123 characters in body; added 2 characters in body
Source Link
Yu-Sung Chang
  • 7.1k
  • 1
  • 40
  • 31

Maybe NotebookDynamicExpression is what you are looking for:

SetOptions[EvaluationNotebook[], NotebookDynamicExpression :> Refresh[ SetDirectory[NotebookDirectory[]]; nbs = {"one.nb", "two.nb", "three.nb"}; For[i = 1, i <= Length[nbs], i++, Block[{nb = NotebookOpen[NotebookDirectory[] <> nbs[[i]]]}, FrontEndTokenExecute[nb, "EvaluateNotebook"]]], None]] 

Then you can erase this cell and save the notebook. Upon the opening of the said notebook, it will open and evaluate one.nb, two.nb, and three.nb.

Refresh[..., None] is used to make sure that it is evaluated once.

Note: Besides, it is in fact Dynamic, it will complain at the beginning if the notebook is not in the trusted path...

Maybe NotebookDynamicExpression is what you are looking for:

SetOptions[EvaluationNotebook[], NotebookDynamicExpression :> Refresh[ SetDirectory[NotebookDirectory[]]; nbs = {"one.nb", "two.nb", "three.nb"}; For[i = 1, i <= Length[nbs], i++, Block[{nb = NotebookOpen[NotebookDirectory[] <> nbs[[i]]]}, FrontEndTokenExecute[nb, "EvaluateNotebook"]]], None]] 

Then you can erase this cell and save the notebook. Upon the opening of the said notebook, it will open and evaluate one.nb, two.nb, and three.nb.

Refresh[..., None] is used to make sure that it is evaluated once.

Maybe NotebookDynamicExpression is what you are looking for:

SetOptions[EvaluationNotebook[], NotebookDynamicExpression :> Refresh[ SetDirectory[NotebookDirectory[]]; nbs = {"one.nb", "two.nb", "three.nb"}; For[i = 1, i <= Length[nbs], i++, Block[{nb = NotebookOpen[NotebookDirectory[] <> nbs[[i]]]}, FrontEndTokenExecute[nb, "EvaluateNotebook"]]], None]] 

Then you can erase this cell and save the notebook. Upon the opening of the said notebook, it will open and evaluate one.nb, two.nb, and three.nb.

Refresh[..., None] is used to make sure that it is evaluated once.

Note: Besides, it is in fact Dynamic, it will complain at the beginning if the notebook is not in the trusted path...

Source Link
Yu-Sung Chang
  • 7.1k
  • 1
  • 40
  • 31

Maybe NotebookDynamicExpression is what you are looking for:

SetOptions[EvaluationNotebook[], NotebookDynamicExpression :> Refresh[ SetDirectory[NotebookDirectory[]]; nbs = {"one.nb", "two.nb", "three.nb"}; For[i = 1, i <= Length[nbs], i++, Block[{nb = NotebookOpen[NotebookDirectory[] <> nbs[[i]]]}, FrontEndTokenExecute[nb, "EvaluateNotebook"]]], None]] 

Then you can erase this cell and save the notebook. Upon the opening of the said notebook, it will open and evaluate one.nb, two.nb, and three.nb.

Refresh[..., None] is used to make sure that it is evaluated once.