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

open all documents of book

New Here ,
Aug 11, 2013 Aug 11, 2013

Copy link to clipboard

Copied

Hello!

Me again, writing with Google Translate,  i'm sorry!

I'm pretty begins on the subject, hope this forum even for beginners.

If not, tell me and run away ...

Two questions:

A. Theoretically. When should I use "getElements" in addition to "everyItems"?

In. Why this script does not open all my book documents?

(Nothing happens)

if (app.activeBook! = undefined) {

     myBook = app.activeBook;

     for (var a = 0; a <myBook.bookContents.length; a + +) {

       myItem = myBook.bookContents.item (a);

       var myS = myBook.bookContents.item (a). status;

     if (myS! = "DOCUMENT_IS_OPEN") {

           app.open (myItem.filePath);

          }

         }

     }

Thank you!

TOPICS
Scripting

Views

658

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
Enthusiast ,
Aug 11, 2013 Aug 11, 2013

Copy link to clipboard

Copied

Hello 13177el,

Use the below code, may it help to open the all book contents

Simple code:

if(app.books.length==0)

{

    alert("please open the book")

    }

var myBook = app.activeBook;

var myBookContents = app.activeBook.bookContents;

for(k=0; k<myBookContents.length; k++)

{

    var myTotalContents = myBookContents.fullName.toString()

    app.open(File(myTotalContents))

    }

For question A:

getElements(): Used to store the some values in the variable like

app.activeDocument.paragraphStyles.everyItem().getElements()

app.activeDocument.characterStyles.everyItem().getElements()

app.activeDocument.objectStyles.everyItem().getElements()

If the above code helps for you, then please click help or correct answers for me.

Thanks

Beginner

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
New Here ,
Aug 11, 2013 Aug 11, 2013

Copy link to clipboard

Copied

Thank you!!!

It worked.

(Just now I have to cancel the dialogues of rebounding questions...)

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
New Here ,
Oct 08, 2023 Oct 08, 2023

Copy link to clipboard

Copied

Hi! Here is an updated version of that script. Feel free to remove the "book is opened" comment. Was just using it to validate the opened book

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
New Here ,
Oct 08, 2023 Oct 08, 2023

Copy link to clipboard

Copied

quote

Hi! Here is an updated version of that script. Feel free to remove the "book is opened" comment. Was just using it to validate the opened book


By @Jaime327835277k0z



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
New Here ,
Oct 08, 2023 Oct 08, 2023

Copy link to clipboard

Copied

LATEST

if (app.books.length == 0) {
alert("Please open the book");
} else {
alert("Book is opened");
}

var myBook = app.activeBook;
var myBookContents = myBook.bookContents;

// Array to store opened documents
var openedDocuments = [];

for (var k = 0; k < myBookContents.length; k++) {
var myTotalContents = myBookContents[k].fullName.toString();
var openedDocument = app.open(File(myTotalContents));
openedDocuments.push(openedDocument);
}

// Now, the opened documents are stored in the 'openedDocuments' array

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