# Get context from notebook

The function Context[] returns the context of the Notebook the function is called in.

Is there a function where we can specify e.g a Notebook object and retrieve the context from that file?

I'm creating a palette where I want to change a variable located in a Notebook that has the context local to that notebook. From the palette I would like to use SelectedNotebook[] and retrieve the context.

• Also, Context[] does not need to be notebook's CellContext, e.g. if Begin/BeginPackage was used. – Kuba Sep 8 '17 at 10:00
• Do you really need a palette? Would a function (loaded from a package) work instead? How about a palette that writes myFunction[data] into the notebook (perhaps along with a Needs)? Maybe automatically insert that as an input cell, then evaluate it. Maybe even delete it after evaluation, if that's what you prefer. – Szabolcs Sep 8 '17 at 14:48