Find a Notebook’s NotebookObject Identifier
To operate on a notebook programmatically, you usually need to know the corresponding NotebookObject identifier. Here is how to find the NotebookObject that corresponds to a given notebook window.
For the Notebook That Contains the Evaluation...
Get the NotebookObject of the notebook that contains the evaluation
EvaluationNotebook returns the NotebookObject identifier of the notebook in which it is evaluated:
- Other notebooks you might want access to are returned by the related functions InputNotebook, SelectedNotebook, ButtonNotebook and ParentNotebook.
Use the NotebookObject in a computation
Get the filename of the evaluation notebook:
For a Given Notebook on the Screen...
Get the list of currently open notebooks
Get the list of the currently open notebooks. The output indicates notebooks by window title:
Index the notebook list with the position of the notebook you want
Find the position of the notebook you want in the list. Use the position as an index to pull out the notebook you want—for example, the World Time notebook:
Use the NotebookObject in a computation
Get the directory that contains the World Time notebook:
Get the NotebookObject of the notebook that contains the evaluation
EvaluationNotebook returns the NotebookObject identifier of the notebook in which it is evaluated:
Use the NotebookObject in a computation
Get the file name of the evaluation notebook:
Get the NotebookObject of the notebook that contains the evaluation
EvaluationNotebook returns the NotebookObject identifier of the notebook in which it is evaluated:
Use the NotebookObject in a computation
Get the filename of the evaluation notebook: