Highlighted

How to switch to the book window

Advocate ,
Feb 29, 2016

Copy link to clipboard

Copied

Dear friends and experts,

After performing a number of actions on the files of a book the last document is open and active.

Now I should re-activate the book window to perform another set of actions (running through the book components).

I have not found a method to switch/activate to the book window in a script.

if (app.FirstOpenBook.ObjectValid()){
  alert ("We have a book") };
else { alert ("There is no book in this session")};

I can assure with this that there is a book, but how to make it active?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Hi Klaus,

You can store the book object in a variable so you can refer to it later. So you could do this:

if (app.FirstOpenBook.ObjectValid ()) {

    var book = app.FirstOpenBook;

}

else {

    alert ("There is no open book in this session.");

}

or if the book is active when you start:

if (app.ActiveBook.ObjectValid ()) {

    var book = app.ActiveBook;

}

else {

    alert ("There is no active book.");

}

Now when you need to refer to the book in later code, just use the book variable from line 02.

-Rick

TOPICS
Scripting

Views

240

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to switch to the book window

Advocate ,
Feb 29, 2016

Copy link to clipboard

Copied

Dear friends and experts,

After performing a number of actions on the files of a book the last document is open and active.

Now I should re-activate the book window to perform another set of actions (running through the book components).

I have not found a method to switch/activate to the book window in a script.

if (app.FirstOpenBook.ObjectValid()){
  alert ("We have a book") };
else { alert ("There is no book in this session")};

I can assure with this that there is a book, but how to make it active?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Hi Klaus,

You can store the book object in a variable so you can refer to it later. So you could do this:

if (app.FirstOpenBook.ObjectValid ()) {

    var book = app.FirstOpenBook;

}

else {

    alert ("There is no open book in this session.");

}

or if the book is active when you start:

if (app.ActiveBook.ObjectValid ()) {

    var book = app.ActiveBook;

}

else {

    alert ("There is no active book.");

}

Now when you need to refer to the book in later code, just use the book variable from line 02.

-Rick

TOPICS
Scripting

Views

241

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Feb 29, 2016 0
Adobe Community Professional ,
Feb 29, 2016

Copy link to clipboard

Copied

Hi Klaus,

You can store the book object in a variable so you can refer to it later. So you could do this:

if (app.FirstOpenBook.ObjectValid ()) {

    var book = app.FirstOpenBook;

}

else {

    alert ("There is no open book in this session.");

}

or if the book is active when you start:

if (app.ActiveBook.ObjectValid ()) {

    var book = app.ActiveBook;

}

else {

    alert ("There is no active book.");

}

Now when you need to refer to the book in later code, just use the book variable from line 02.

-Rick

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 29, 2016 0
K.Daube LATEST
Advocate ,
Feb 29, 2016

Copy link to clipboard

Copied

Rick, as often I was to fearful just to try something:

As You point out it's that simple:

if (app.FirstOpenBook.ObjectValid()){
  alert ("We have a book")
  book = app.FirstOpenBook;
  bookComp = book.FirstComponentInBook
  while(bookComp.ObjectValid()) {                 // process only FM docs
    if (bookComp.BookComponentFileType === Constants.FV_BK_FM) {
      docName = bookComp.Name;
      alert ("docName= "+ docName);
    }
    bookComp = bookComp.NextBookComponentInDFSOrder;
  }
};
else { alert ("There is no book in this session")};

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Feb 29, 2016 0