2 Replies Latest reply on Jun 10, 2014 2:51 AM by Laubender

    GREP optical

    Dapeamel Level 1

      Hello guys,

       

      why does not this work?

      I want to change the kerning on  (findwhat)

       

       

      var sel = app.activeDocument.selection;

       

      app.findTextPreferences=app.changeTextPreferences=null;

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences = NothingEnum.nothing;

      app.findGrepPreferences.findWhat="\d{1,4},-";

      app.changeGrepPreferences.changeTo="$0";

      app.changeGrepPreferences.kerningMethod="optical";

      app.activeDocument.changeGrep();   

       

       

       

       

      please help me out

       

       

      thank you in advance.

        • 1. Re: GREP optical
          [Jongware] Most Valuable Participant

          You clear the findTextPreferences but not the findGrepPreferences. That may be the problem.

           

          Scripting related questions are best asked in the forum called "InDesign Scripting Forum": InDesign Scripting

          • 2. Re: GREP optical
            Laubender Adobe Community Professional & MVP

            @Dapeamel – several things here:

             

            1. Your changeGrep() targets the whole document.

            If you want this, you need no selection in line one of your script

             

            2. Your GREP expression cannot work, because you did not escape your escape character

             

            3. You need not change to $0; just do without that line

             

            That said, the following should work targeting the whole active document:

             

            app.findGrepPreferences = app.changeGrepPreferences = null;
            
            app.findGrepPreferences.findWhat="\\d{1,4},-";
            app.changeGrepPreferences.kerningMethod="optical";
            
            app.activeDocument.changeGrep();
            

             

            However it will not work in an eg. German version of InDesign, because the String value must be different there.

             

            Uwe