6 Replies Latest reply on Mar 14, 2017 8:22 AM by jakec88782761

    Track changes report

    jakec88782761 Level 1

      Hi guys,

       

      I'm trying to get a list of all the changes I make in the document.

      It works on a small one page document with a couple of stories.

       

      When I try it on a large document it takes so long! It's never actually finished, it just keeps running and the console always says that i=1.

       

      Any ideas as to why or how I can speed it up?

       

       

      var doc = app.activeDocument,
      myStories = doc.stories.everyItem().getElements(),
      myChanges;
      var changes = [];
      // set userName
      if ( app.userName == "Unknown User Name" ) {
          
          var name = prompt( "What's your name?" );
          app.userName = name;
          
          }
      // turn on track changes 
          
      for ( var i = 0; i < myStories.length; i++ ) {
          
          
              if ( myStories[i].trackChanges === false ) {
              
                  myStories[i].trackChanges = true;
              }
          
          var story = myStories[i];
          myChanges = story.changes.everyItem().getElements();
          
          
              if ( myChanges  !== 0 ) {
              
                  for ( var i = 0; i < myChanges.length; i++ ) {
                  
                  changes.push( myChanges[i].date + '\n' +
                  myChanges[i].userName + '\n' +
                  myChanges[i].changeType + ': ' + myChanges[i].lines[0].contents + myChanges[i].texts[0].contents );
                  
                  }
              
              }
          
       }
      $.writeln(changes);