• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to switch to the book window

Community Expert ,
Feb 29, 2016 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

440

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
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 29, 2016 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.

-

...

Votes

Translate

Translate
Community Expert ,
Feb 29, 2016 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

Votes

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
community guidelines
Community Expert ,
Feb 29, 2016 Feb 29, 2016

Copy link to clipboard

Copied

LATEST

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")};

Votes

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
community guidelines