2 Replies Latest reply on Sep 20, 2008 8:13 AM by Loic.Aigon

    [CS2] [JS] how to replace text in specific table column

      Hi all.

      I need to run a "find & replace text" that is restricted to a specific column in a series of similar tables.

      For example: Run down all cells in Col 3 and replace "A" with "B".

      I'm using this code which works OK globally, but I'm struggling to find the JS syntax that limits the F&R activity to a selection.

      app.findPreferences = app.changePreferences = null;
      app.activeDocument.search( 'A', true, false, 'B' );

      Can anyone please advise how to limit the F&R to a selection?

      thanks

      Greg
        • 1. Re: [CS2] [JS] how to replace text in specific table column
          Level 1
          Problem solved! It wasn't my selection syntax (red herring).

          I was trying to swap decimal points and commas within a table column (German decimal numeric conventions) and my F&R code was ignoring the '.' in the search criteria.

          I found using '\.' to escape the character works OK as well as using variables to hold search strings.

          Phew!

          Back to the grindstone. :)

          Greg
          • 2. Re: [CS2] [JS] how to replace text in specific table column
            Loic.Aigon Adobe Community Professional
            I arrived after the battle :-( but if it may help you in anyway, here what I wrote.<br />It seemed to work on my CS3:<br /><br />app.findTextPreferences = NothingEnum.nothing; <br />app.changeTextPreferences = NothingEnum.nothing; <br />app.findTextPreferences.findWhat = "A";<br />app.changeTextPreferences.changeTo = "B"<br />var myAs= app.activeDocument.findText();<br />for(i=0; i<myAs.length; i++)<br />{<br />  if(myAs[i].parent.parentColumn.index==2)<br />  {<br />    myAs[i].changeText ();  <br />  }<br />}<br />Loic