2 Replies Latest reply on Aug 11, 2013 4:26 PM by 131772el

    open all documents of book

    131772el Level 1

      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!

        • 1. Re: open all documents of book
          BEGINNER_X Level 3

          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[k].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

          1 person found this helpful
          • 2. Re: open all documents of book
            131772el Level 1

            Thank you!!!

            It worked.

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