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?

TOPICS
Scripting

Views

278

Likes

Translate

Translate

Report

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

1 Correct Answer

Adobe Community Professional , Feb 29, 2016
frameexpert Adobe Community Professional , Feb 29, 2016
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.-...

Likes

Translate

Translate
Jump to answer Jump to answer
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
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
K.Daube AUTHOR 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
Reply
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more