2
$\begingroup$

I want to find all of the stylesheet notebooks currently open. Is there a modestly fast way to get at this?

$\endgroup$
1
$\begingroup$

This is somewhat slow, but it gets the job done:

AbsoluteTiming[
 sDefs =
  AssociationMap[
   Key["StyleDefinitions"]@*Association@*NotebookInformation,
   FrontEndExecute@
    FrontEnd`ObjectChildren[$FrontEnd]
   ];
 styleNotebooks =
  Cases[Keys@sDefs,
   Alternatives @@
    Flatten[DeleteCases[Values@sDefs, None]]
   ]
 ]

{0.069589, {NotebookObject[Defer[$FrontEnd], 243], 
  NotebookObject[Defer[$FrontEnd], 83], 
  NotebookObject[Defer[$FrontEnd], 220], 
  NotebookObject[Defer[$FrontEnd], 215], 
  NotebookObject[Defer[$FrontEnd], 105], 
  NotebookObject[Defer[$FrontEnd], 4], 
  NotebookObject[Defer[$FrontEnd], 5], 
  NotebookObject[Defer[$FrontEnd], 6], 
  NotebookObject[Defer[$FrontEnd], 75], 
  NotebookObject[Defer[$FrontEnd], 81], 
  NotebookObject[Defer[$FrontEnd], 82], 
  NotebookObject[Defer[$FrontEnd], 104], 
  NotebookObject[Defer[$FrontEnd], 106], 
  NotebookObject[Defer[$FrontEnd], 107], 
  NotebookObject[Defer[$FrontEnd], 186], 
  NotebookObject[Defer[$FrontEnd], 229], 
  NotebookObject[Defer[$FrontEnd], 230]}}

It could be made faster if I knew how to get the NotebookInformation to vectorize in a single call to the FE, but alas I don't.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.