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.
(1)
Make a button that sets to the NotebookObject for the button's notebook:
After the button is clicked, the variable is assigned:
Use the object for further processing:
Make a button that sets to the NotebookObject for the button's notebook:
Out[1]=
After the button is clicked, the variable is assigned:
Out[2]=
Use the object for further processing:
Out[3]=
(1)
Create a palette button that writes to the input notebook and then closes the palette:
(1)
The button notebook is sometimes not the same as the current input notebook:
After clicking the button, these two notebooks are different: