Thanks for coming to, the world's #1 resource for all things InDesign!

Open All or Close All in the Book Panel Menu

In the Book panel menu you can double-click any single document to open it, and you can use Ctrl/Cmd+click to select more than one document as well — but this is a bit cumbersome if you want to open all documents. Besides, once you opened all documents of a single book, you might want to close them all again. There is a hidden shortcut to close all documents (it’s Cmd/Ctrl+Shift+Alt+W) — but what if you have other files open as well and you want to keep them open (while closing the book documents)?

I’m going to show how you can do this easily with Javascript, but fear not: If you’re not a scripter you’ll still be able to take advantage of the feature with an easy download and install!

Figuring it Out

With Javascript you have access to the file names that make up your Book and so you can do something with them. Here, for example, is a small script that shows file names and page ranges:

var book = app.activeBook;
var text = '';

for (var d=0; d<book.bookContents.length; d++)
text += book.bookContents[d].fullName + ' = ' + book.bookContents[d].documentPageRange + '\r';
alert (text);

Opening all of them is easy: just issue the command (book.bookContents[d].fullName);

for each of the files. Closing the right documents, however, needs a trick, because a document doesn’t ‘know’ to which book it’s associated. The easiest way to make sure the right document closes is to open it using the line above, and then close this new document straight away.

That would make two nice new scripts, but it’s even nicer when you can add them as proper menu commands to the Book Panel menu! I’ve never added menu items before, but fortunately Marc Autret wrote a blog post on this (How to Create Your Own InDesign Menus), and then it only took some fidgeting to replace his example with my code to open and close book documents.

Download the Script

The complete script can be downloaded from my site.

This is not a regular script, as it must always stay in memory and be ready to be called upon, and so you must not copy it into the usual place (your User Scripts folder). Instead, you place it in a special folder called “Startup Scripts”. To get to the correct location in one single step, right-click the folder “User” in the Scripts panel and choose “Reveal in Explorer/Finder”. You will see the regular folder “Scripts Panel” in which everything in the Scripts panel is stored — but don’t put this script in there! Instead, unpack the zip file at this location; it will add the folder “Startup Scripts” automatically.

Then restart InDesign, and open or create a Book file, and look in the book panel menu to check if it works:

Yes it does, and from now on we have our useful new options ready to go!

A note on “activeBook”

One more note, in case you’re going to be scripting book panels: Before you add your own custom options to the Book panel, you have to make sure it works as intended in a standalone script. Now there is something weird going on when using ‘activeBook’. Other than, say, ‘activeDocument’, ‘activeBook’ does not always get right what book document is the active one! The reason for this is that you can have several book panels open at a time, scattered about your workspace. Which one is then “active”? So when experimenting with this, you’d better make sure you only have one single book open.

I was kind of weary of this issue when testing my open/close script, but it seems that if you call a script from within the book panel itself, ‘the’ active book is indeed the one you called the menu from, so the problem resolved itself.

Theunis De Jong

Theunis De Jong

Dutchman Theunis de Jong is better known under his nickname "Jongware" and has been bothering people since 1966. Started as pressman's little helper in 1984, fresh from school. Really wanted to work in the graphics industry, so he had no problems starting at the very bottom :-) His computer talents were soon discovered, first by himself (being a math & science buff), then by his boss who quickly promoted him to the typesetter division. Worked with WordPerfect, PageMaker, and now InDesign -- but never with Quark. Well, hardly ever. Tends to dive in deep into technical stuff: PostScript, XML, XSLT, general programming in C++ (for DOS, Windows, and Mac OS X). Wrote programs in pure assembler for Z80, ARM4, 80x86, and 68000 processors. As it appeared, this seems the perfect background for right-brain activities such as Scripting and GREP, two InDesign features he fanatically uses (and occasionally abuses). Or was it left-brain? I always forget. I mean, he always forgets.
Theunis De Jong

Latest posts by Theunis De Jong (see all)

  • - November 30, -0001
Related Articles

24 Comments on “Open All or Close All in the Book Panel Menu

  1. Anne-Marie, that would require adding three options: save all, discard all, or You Decide … At present it issues a “close” command and the usual confirmation dialog appears for un-saved documents only.

    Usually I issue a “Save All” manually, just to make sure: Cmd+Shft+Alt+S. That way I can’t accidentally choose “no”, as a collegaue of mine once did (lots of laughs all around — but not from him!).

  2. F., ouch!

    The script locates the “Book Panel Menu”, and then inside that the menu item called “Close Book”. It needs to find that particular item because that’s where the new menu items should be added.

    Adobe attempted to create a system where you can use ‘global’ names — not translated — which ought to work for every localized version as well. Unfortunately, they neglected to state where on would find the ‘global’ names for everything … And I blindly assumed these would match the US English version … :(

  3. I’ve been nagging for a couple of years for this functionality to be made part of the book panel. This is a great substitute, particularly as I generally use Close All anyway!

    Worth noting: In CS6 the startup scripts directory is already there. It contains one file, ForceDirectory.txt, which contains this text:

    “Short Story:
    This file exists solely to force the source code version control system to create this directory/folder.”

  4. Thanks for sharing. I regularly use book panels with many documents. This is a real time-saver.
    Besides, sometimes the hidden shortcut Cmd/Ctrl+Shift+Alt+W makes my InDesign crash.

  5. Jongware,


    CS 5.5 quit unexpectedly when I invoked the command to Close all documents. It opened them OK, however,

  6. Jongware,

    awhile back I started a book feature plug-in that had it working similar other menu items. It would close only selected documents, if selected. and all documents if none were selected.

    The bug you point out, I had reported to adobe during CS4. The bug is that bringing book panel to the front does not make it the active book. However clicking on the menu flyout does make it the active book. So as long as you use the menu, you should be ok. However a keyboard shortcut is where the bug will show its ugly face.

    For the positioning of the menu. The numeric position of Close book is 700 and Separator is 800, so any number in between should have you in the right spot.

  7. Sandee, that’s not what’s supposed to happen … When closing files, the script does absolutely nothing unusual. Do you get your ID to crash for every book you try?

    (And for the curious ones:

    Steven checked the Software Development Kit for InDesign, as it contains a wealth of “behind the scenes” documentation. In this, menus are not located by name, but by a numerical index instead. Here Adobe did Think Ahead, and they left huge free ranges in between the positions they used for the standard menu items.

    Alas. As Steven says, with a script you cannot insert a menu ‘by number’, only ‘by name’. And the SDK fails to tell me what those names are.)

  8. BTW the correct key string is “$ID/Close Book Menu Item”. I do have a csv file with a dump from the debug containing all these goodies (from CS4). You know how to contact me …

  9. I’ve wondered and wondered why/how one would open and close all book documents. Now this wonderful script has been produced. Thank you SO much Jongware — very much appreciated.

  10. I create books all the time and always wanted this feature (which is standard in Adobe’s FrameMaker). I just downloaded and tested it and it works like a dream. This is going to save tons of time — thanks very much!!

  11. In the English version at least, you can select all the desired chapters in a book, and the double-click on one of them. It appears as if only one is selected when you double-click, but all the selected documents will open.

    Then I use the Cmd/Cntl-Opt/Alt-Shift-S to save them all at once.

    And I use the Cmd/Cntl-Opt/Alt-Shift-W to close them all at once.

  12. @David C. — of course, but using a menu is more convenient! In addition, my “Close book document” close just that Book’s documents, not all opened. Personally, I find that very useful, as I tend to have lots of unrelated docs open as well.

  13. Generally, for efficiency I prefer keyboard shortcuts over menus.

    If I’m working on a large, multi-chapter book, I usually don’t open up other ID documents at the same time (since I can confuse myself very easily…).

    That being said, I think that your script (as are all of your scripts) is very useful.

  14. After using this handy add-on for a while i think it would be very nice to have also the command ‘Save book documents’.

  15. Hi Jongware and all,
    I have written a similar script on my own to open/close all files in a book but I don’t know if anyone mentioned that by selecting one file and then holding Shift and double-clicking another one, above or below (including however many files in between) would open them all. Also Ctrl+Shift+Alt+S would save all and Alt+Ctrl+Shift+W would close all files.
    Next step I’m looking to implement is to open SELECTED documents. Book and BookContent don’t seem to have any property that would allow selecting or using selected book files. Any ideas?


    • Michael,

      I know this is an ancient post, but just in case you are still struggling with this, if you open up the book panel, and select just the documents that you want to open (using Ctrl+Click on the PC; don’t know the Mac equivalent), then double-click on one of the selected documents, InDesign will open only those documents that you selected in the book list.

  16. I know this is an old thread, but I just installed the script and used it on a book in InDesign CC2014 on Windows 8.1 and it worked like a charm. So happy! I need to open all of the files in this book to avoid performance hits from the cross-references, TOC, and index markers. Thank you so much.

    • You need to remember that if you open an older book, you have to re-save all of its documents as (Your New Version Here). My script does NOT automatically do so for you.

      I did get some weird behavior before I realized I had to do that first.

Leave a Reply

Your email address will not be published. Required fields are marked *