gives the notebook, if any, that contains the button which initiated the current evaluation.
ButtonNotebook
gives the notebook, if any, that contains the button which initiated the current evaluation.
Details
- ButtonNotebook returns a NotebookObject.
- If a button in a palette initiates evaluation in another notebook, then ButtonNotebook[] will be the palette, but EvaluationNotebook[] will be the other notebook.
- If the current evaluation was not initiated by a button, then ButtonNotebook[] will return $Failed.
Examples
open all close allBasic Examples (1)
Make a button that sets nb to the NotebookObject for the button's notebook:
Button["Set nb", nb = ButtonNotebook[]]After the button is clicked, the variable is assigned:
nbUse the object for further processing:
Options[nb, WindowSize]Applications (1)
Properties & Relations (1)
The button notebook is sometimes not the same as the current input notebook:
Button["New notebook", CreateDocument[];bnb = ButtonNotebook[]; inb = InputNotebook[]]After clicking the button, these two notebooks are different:
"WindowTitle" /. (NotebookInformation /@ {bnb, inb})Tech Notes
Related Guides
Related Workflows
- Create a Palette ▪
- Find a Notebook's Notebook Object Identifier
History
Introduced in 1996 (3.0)
Text
Wolfram Research (1996), ButtonNotebook, Wolfram Language function, https://reference.wolfram.com/language/ref/ButtonNotebook.html.
CMS
Wolfram Language. 1996. "ButtonNotebook." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ButtonNotebook.html.
APA
Wolfram Language. (1996). ButtonNotebook. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ButtonNotebook.html
BibTeX
@misc{reference.wolfram_2026_buttonnotebook, author="Wolfram Research", title="{ButtonNotebook}", year="1996", howpublished="\url{https://reference.wolfram.com/language/ref/ButtonNotebook.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_buttonnotebook, organization={Wolfram Research}, title={ButtonNotebook}, year={1996}, url={https://reference.wolfram.com/language/ref/ButtonNotebook.html}, note=[Accessed: 12-June-2026]}