({{, (RefLink[NotebookGet, paclet:ref/NotebookGet])[obj]
gets the raw expression corresponding to the notebook represented by the notebook object obj. }, {, (RefLink[NotebookGet, paclet:ref/NotebookGet])[]
gets the raw expression corresponding to the currently selected notebook. }})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[NotebookGet, paclet:ref/NotebookGet]) allows you to take a notebook that is open in the front end, and get the raw expression corresponding to it in the kernel.

(RefLink[NotebookGet, paclet:ref/NotebookGet]) returns an expression with head (RefLink[Notebook, paclet:ref/Notebook]), containing (RefLink[Cell, paclet:ref/Cell]) expressions and boxes data.

(RefLink[NotebookGet, paclet:ref/NotebookGet])[(RefLink[NotebookOpen, paclet:ref/NotebookOpen])[file]] returns the same expression as (RefLink[Get, paclet:ref/Get])[file].

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

First create a small sample notebook to operate on:

nb=NotebookPut[Notebook[{Cell["Subsection heading","Subsection"],Cell["Some text.","Text"]}]];

Get the notebook expression of the small sample notebook:

NotebookGet[nb]

OpenersExampleSection1(Spacer1)Applications  (1)

nb=NotebookPut[Notebook[{Cell["Mathematical Constants", "Subsection"],Cell["pi", "Text"]}]];

Find subsection titles:

Cases[NotebookGet[nb],Cell[t_,"Subsection",___]:>t,Infinity]

Change Subsection-style cells to Section style:

NotebookPut[NotebookGet[nb]/.Cell[c_, "Subsection",o___]:>Cell[c,"Section",o],nb];

OpenersExampleSection2(Spacer1)Properties & Relations  (1)

(RefLink[NotebookRead, paclet:ref/NotebookRead]) reads only the selected part of a notebook:

nb=NotebookPut[Notebook[{Cell["first", "Text"],Cell["second", "Text"]}]];

SelectionMove[nb,Next,Cell]

NotebookRead[nb]

(RefLink[NotebookGet, paclet:ref/NotebookGet]) always gets the whole notebook:

NotebookGet[nb]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[NotebookImport, paclet:ref/NotebookImport])  ▪  (RefLink[NotebookOpen, paclet:ref/NotebookOpen])  ▪  (RefLink[NotebookPut, paclet:ref/NotebookPut])  ▪  (RefLink[NotebookRead, paclet:ref/NotebookRead])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Notebooks as Wolfram Language Expressions, paclet:tutorial/NotebooksAsWolframLanguageExpressions])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Low-Level Notebook Programming, paclet:guide/LowLevelNotebookProgramming])}, {▪(RefLinkPlain[Notebook Document Generation, paclet:guide/DocumentGeneration])}})}})