4 Replies Latest reply on Jul 27, 2016 12:03 PM by sarahcoppen

    Trouble Running Script in InDesign CC, Result: undefined

    sarahcoppen

      I am trying to run a script in InDesign that I have run successfully on 2 other documents. Now when I try to run the script on another document that is identical to the ones that used it before it isn't working.

       

      I am using InDesign CC on Windows 10 and have tried running the script both through the ID scripts panel as well as through ExtendScript. When running the script through ExtendScript I receive the message "Result: undefined" under the JavaScript Console. I haven't changed anything in the script and am completely lost.

       

      Disclaimer: I am a scripting novice and don't know anything about the script itself. It was provided by another user as a solution to a design problem I had through another thread. Help?!

       

      Here is the script I am trying to run:

       

      // AddOnePageBeforeAnyPage-AddSections-RenumberPages-SinglePageDocument.jsx 

      // Uwe Laubender 

       

      /**

      * @@@BUILDINFO@@@ AddOnePageBeforeAnyPage-AddSections-RenumberPages-SinglePageDocument.jsx !Version! Tue Jun 21 2016 07:19:25 GMT+0200

      */ 

       

      /*

          See discussion at InDesign forum:

          "Inserting Non-Numbered Pages into Existing Document"

          sarahcoppen Jun 20, 2016

          https://forums.adobe.com/message/8822592#8822592

      */ 

       

       

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll; 

      app.doScript 

          ( 

          

          addPages, 

          ScriptLanguage.JAVASCRIPT, 

          [], 

          UndoModes.ENTIRE_SCRIPT, 

          "Add pages before every page | SCRIPT" 

          

          ); 

       

      function addPages() 

          if(app.documents.length == 0){return}; 

          if(app.documents[0].documentPreferences.facingPages){return}; 

          

          var doc = app.documents[0]; 

          var pages = doc.pages; 

          var pagesLength = pages.length; 

          

          doc.documentPreferences.properties = 

          { 

              allowPageShuffle : true , 

              preserveLayoutWhenShuffling : true 

          } 

          

          for(var n=pagesLength-1;n>=0;n--) 

          { 

              doc.pages.add(LocationOptions.BEFORE , pages[n] , { appliedMaster : NothingEnum.NOTHING } ); 

          } 

       

          doc.documentPreferences.startPageNumber = 2; 

          doc.documentPreferences.facingPages = true; 

          

          doc.documentPreferences.properties = 

          { 

              allowPageShuffle : false , 

              preserveLayoutWhenShuffling : true 

          } 

          

          pages = doc.pages; 

          pagesLength = pages.length; 

          var counter = 0; 

          

          for(var n=1;n<pagesLength;n=n+2) 

          { 

              counter++ 

              doc.sections.add( pages[n] , { continueNumbering : false , pageNumberStart : counter } ); 

          } 

          

      }