Skip to main content
September 19, 2013
Answered

bookContents.add 'at' argument

  • September 19, 2013
  • 1 reply
  • 633 views

Hi There,

I am using the bookContents.add function and I am trying to use the 'at' argument. I set this to the value 0 which I would expect to be the start of a book considering -1 the default value would add it to the end of the book however it adds the document after the first document in the book. WHY?

newBook.bookContents.add(File(outputLocation + saveName + ".indd"), 0);

Thanks!

Matt

This topic has been closed for replies.
Correct answer Laubender

@Matt – if you want to add a file to the beginning of the bookContents collection, first add it to the list and then move it to the beginning:

//Adding the active document at the beginning of the listed Indesign files of a book file:

var d=app.activeDocument;

var b= app.books[0];

//Add the active document to the end of the list:

b.bookContents.add(d.fullName,-1,undefined);

//Move it before the first item of the collection:

b.bookContents[-1].move(LocationOptions.AT_BEGINNING,b.bookContents[0]);

Uwe

1 reply

LaubenderCommunity ExpertCorrect answer
Community Expert
September 19, 2013

@Matt – if you want to add a file to the beginning of the bookContents collection, first add it to the list and then move it to the beginning:

//Adding the active document at the beginning of the listed Indesign files of a book file:

var d=app.activeDocument;

var b= app.books[0];

//Add the active document to the end of the list:

b.bookContents.add(d.fullName,-1,undefined);

//Move it before the first item of the collection:

b.bookContents[-1].move(LocationOptions.AT_BEGINNING,b.bookContents[0]);

Uwe

September 20, 2013

Hi Laubender,

Thanks for this! Worked like a treat

Matt