# How to reference a cell in a different notebook

I am creating a 'Table of contents' (TOC) generator not unlike the AuthorTools. My "generator" creates cells like the following in the TOC.nb:

Cell[
TextData[{
CounterBox["Chapter",
{FrontEndFileName[{$RootDirectory, "X:","Daten","fh-fsi-beuth", "Test-HeaderFooter.nb" }, CharacterEncoding -> "WindowsANSI" ], "testTag" } ], " Allgemeine Grundlagen", " ", Cell[ TextData[ ButtonBox[ CounterBox["Page", {FrontEndFileName[{$RootDirectory, "X:","Daten","fh-fsi-beuth",
}, CharacterEncoding -> "WindowsANSI"
],
"tagTest"
}
],
]
],
"TOCPage"
]
}
],
"TOCChapter"
]


The link in the ButtonData-Rule works, I can jump right into the target notebook (which is assumed to be open). But neither the Chapter number nor the Page number is generated. Here the error message is, that the notebook is not found.

My question is, what is the right syntax for CounterBox["Chapter",{???????, "testTag"}] and how can I produce it from my "TOCgenerator"?

• For the page number to work it might be that you have to set the option "Show Page Breaks" in File>Printing Settings. – Sjoerd C. de Vries Feb 29 '16 at 21:54
• Related: 476. – Sjoerd C. de Vries Feb 29 '16 at 21:58
• Thank you very much for your fast comment. This is one of the first steps I do with the target notebook. I found out it all depend on first saving both notebooks AND to evaluate just something in the TOC notebook (3+7). – Darwin1871 Feb 29 '16 at 22:38