5 Replies Latest reply on Apr 6, 2016 12:45 AM by BEGINNER_X

    Find & Replace as per page only (not for Document)

    BEGINNER_X Level 3

      Hi All,

       

      Customer provided the Word document in Table format (around 200 Pages).

      Need to find Column1 text and change Column2 text in the Indesign Document.

       

      So, I flow the word file in Pasteboard and need to do the changes in the Indesign document as per PAGE.

       

      FYI, trying sample reference Indesign file Screenshots,

       

      Screen Shot 2016-04-06 at 06.25.07.png

      Screen Shot 2016-04-06 at 06.25.21.png

      Screen Shot 2016-04-06 at 06.25.30.png

       

      Script got from Forum, but it works for Whole document not for Page Sequence.(clarify in 16th line)

       

      the_table = app.selection[0].tables[0];  
      app.findChangeTextOptions = null;  
      with (app.findChangeTextOptions)  
      {  
       caseSensitive = true;  
       wholeWord = true;  
      }  
      app.findTextPreferences = null;  
      app.changeTextPreferences = null;  
      for (row=0; row<the_table.rows.length; row++)  
      {  
         if (the_table.rows[row].cells[0].contents == '')  
           continue;  
         app.findTextPreferences.findWhat = the_table.rows[row].cells[0].contents;  
         app.changeTextPreferences.changeTo = the_table.rows[row].cells[1].contents;  
         app.activeDocument.changeText();  
      }  
      
      

      Thanks in Advance

      Siraj

        • 1. Re: Find & Replace as per page only (not for Document)
          b91823603 Level 3

          Hi

           

          You could try this,

           

          var myTable = app.selection[0].tables[0];   

          var myRows = myTable.rows;

          for (i=0; i<myRows.length; i++)   

          {

              myRows[i].cells[0].contents = myRows[i].cells[1].contents;

          }

          • 2. Re: Find & Replace as per page only (not for Document)
            BEGINNER_X Level 3

            Thank you for quick response...

             

            But, I need changes only in Particular page wise (not for document).

             

            Please see the PasteBoard Text in Screenshot.

            • 3. Re: Find & Replace as per page only (not for Document)
              b91823603 Level 3

              Hi,

               

              It will replace contents based on the text frame selection only. It will not change all document text frames.

              • 4. Re: Find & Replace as per page only (not for Document)
                b91823603 Level 3

                You could use your code also, You need to change the 16th line as below for replace contents only in selected table,

                 

                the_table.changeText();

                • 5. Re: Find & Replace as per page only (not for Document)
                  BEGINNER_X Level 3

                  Thank You Dillibabu...

                   

                  I write the below script with the help of existing script. Working Fine in testing file.

                   

                  the_table = app.selection[0].tables[0];  
                  app.findChangeTextOptions = null;  
                  app.findChangeTextOptions.wholeWord = false;
                  app.findChangeTextOptions.caseSensitive = false;
                  app.findTextPreferences = app.changeTextPreferences =null;  
                  
                  
                  for (row=0; row<the_table.rows.length; row++)  
                  {  
                    if (the_table.rows[row].cells[0].contents.match(/PAGE \d+/i) != null)
                    {
                        var myPage_Text = the_table.rows[row].cells[0].contents;
                        //alert("myPage_Text: " + myPage_Text)
                        
                        var myPage = String(myPage_Text).replace("page ", "");
                        alert(myPage)
                        }
                    
                    app.documents[0].pageItems.everyItem().locked = true;  
                    //app.documents[0].pages.itemByRange(2,2).pageItems.everyItem().locked = false;  
                    app.documents[0].pages.item(myPage).pageItems.everyItem().locked = false;  
                  
                     app.findTextPreferences.findWhat = the_table.rows[row].cells[0].contents;  
                     //alert("To Find: " + the_table.rows[row].cells[0].contents)
                     app.changeTextPreferences.changeTo = the_table.rows[row].cells[1].contents;  
                     //alert("To Change: " + the_table.rows[row].cells[1].contents)
                     app.activeDocument.changeText();  
                     }
                  
                    app.documents[0].pageItems.everyItem().locked = false;  
                  

                   

                  Thanks

                  Siraj