4 Replies Latest reply on Jun 10, 2016 4:14 AM by Bubunator

    find highlighted text




      I would like to remove all conditional text.  The background of the text is YELLOW.


      Can I use findtextpreferences or something?


      PLEASE HELP!!!

        • 1. Re: find highlighted text
          DaveSofTypefi Level 2

          How does conditional text work? I've never used it. Let's look in the OMV ...


          What happens if you just remove the conditions replacing with empty strings? Does that do the job? No it doesn't -- my asking that question reflects my ignorance of how conditions work. The string needs to be the name of another condition, so going at it that way won't work. Although it does raise the question: do you want to delete the text (as you said) or remove the condition? Because if the latter, then you should be able to simply remove the condition and replace it with the first condition which is "no conditions". Wrong again! That first listed "no conditions" is not considered to be a condition. Drat.


          So we can't tackle this from the conditions side. We're going to need to tackle if from the text side.


          Back to the OMV ...


          Well look at that, text and app.findTextPreferences have an appliedConditions property.


          So, find text with the applied condition of interest and then do:


          myFoundText.appliedConditions = [];


          Is this enough information to get you on your way?



          • 2. Re: find highlighted text
            Vamitul Level 4

            Do you need to do it in a script? if not, a simple find/change will do the trick (in the find format dialog you gave a category called "conditions". select the one nedded and replace with nothing).


            if you need to do it in a script, again it's a simple find/change:



            app.findTextPreferences.appliedConditions=['NameOfYourCondition']; //notice it's an array



            • 3. Re: find highlighted text
              [Jongware] Most Valuable Participant

              Onnozel wrote


              The background of the text is YELLOW.


              so I don't think he knows what the names of these conditions are. This will remove the text in any condition with 'background is YELLOW':


              app.findTextPreferences = app.changeTextPreferences = null;
              for (i=0; i<app.activeDocument.conditions.length; i++)
              if (app.activeDocument.conditions[i].indicatorMethod == ConditionIndicatorMethod.USE_HIGHLIGHT &&
                app.activeDocument.conditions[i].indicatorColor == UIColors.YELLOW)
                app.findTextPreferences.appliedConditions = [app.activeDocument.conditions[i]];
              • 4. Re: find highlighted text

                If you want to remove all conditional Text, you can loop though all of your conditions, grab the text they are applied to and remove them, without knowing the conditions name:


                var currConditions = app.activeDocument.conditions; // grab all Conditions

                var chunks;

                var l = currConditions.length;



                     currCondition[0] =     currConditions[l]; // grab the condition at index l

                     app.findGrepPreferences = null 

                     app.findGrepPreferences.appliedConditions = currCondition;

                     chunks = app.activeDocument.findGrep();


                     if(chunks.length > 0){ // check if there are any elements with the current Condition

                          for (var i=0; i<chunks.length; i++){ // loop through them


                                      chunks[i].remove(); // remove them


                                 $.writeln('error:' + e); // have a look in the log, if anything happens







                NOTE: this works only if there's only 1 Condition applied