6 Replies Latest reply on Jan 7, 2015 12:31 AM by hamdifem

    within a text frame linked in the text frame remove

    hamdifem Level 1

      in a document finding the linked text frames

      get out of text (two lines) and I want to delete a text frame

      Is it possible that a command letter

       

      A1.jpg

        • 1. Re: within a text frame linked in the text frame remove
          Chinnadk Level 4

          Try this,

           

          var doc = app.activeDocument;
          app.findGrepPreferences = app.changeGrepPreferences = null;
          app.findGrepPreferences.findWhat = "~a";
          var found = doc.findGrep();
          for(var i =found.length-1;i>=0;i--)
          {
                  var ip = found[i].insertionPoints[0];
                  if(found[i].allPageItems[0].lines.length == 2)
                  {
                          app.findGrepPreferences = app.changeGrepPreferences = null;
                          app.findGrepPreferences.findWhat = "\\r";
                          app.changeGrepPreferences.changeTo = "";
                          found[i].allPageItems[0].texts[0].changeGrep();
                          app.findGrepPreferences = app.changeGrepPreferences = null;
                          found[i].allPageItems[0].texts[0].duplicate(LocationOptions.AFTER,ip);
                          found[i].remove();
                      }
              }
          

           

          Regards,

          Chinna

          • 2. Re: within a text frame linked in the text frame remove
            hamdifem Level 1

            great

            upper case character style bottom case another character style

            Can we apply

            A2.jpg

            • 3. Re: Re: within a text frame linked in the text frame remove
              Chinnadk Level 4

              Try this,

               

              var doc = app.activeDocument; 
              app.findGrepPreferences = app.changeGrepPreferences = null; 
              app.findGrepPreferences.findWhat = "~a"; 
              var found = doc.findGrep(); 
              for(var i =found.length-1;i>=0;i--) 
              { 
                      var ip = found[i].insertionPoints[0]; 
                      if(found[i].allPageItems[0].lines.length == 2) 
                      { 
                              app.findGrepPreferences = app.changeGrepPreferences = null; 
                              app.findGrepPreferences.findWhat = "\\r"; 
                              app.changeGrepPreferences.changeTo = ""; 
                              found[i].allPageItems[0].texts[0].changeGrep(); 
                              app.findGrepPreferences = app.changeGrepPreferences = null; 
                              var cont = found[i].allPageItems[0].texts[0].duplicate(LocationOptions.AFTER,ip); 
                              cont.characters[0].appliedCharacterStyle = doc.characterStyles.item("my character style 1");
                              cont.characters[1].appliedCharacterStyle = doc.characterStyles.item("my character style 2");
                              found[i].remove(); 
                          } 
                  } 
              
              

               

              Regards,

              Chinna

              • 4. Re: within a text frame linked in the text frame remove
                Laubender Adobe Community Professional & MVP

                @Chinna – be aware, that your code will break, if you'll find a different object than a text frame with your inital GREP search. ~a could be any object you can anchor: rectangles, ovals, polygons, MSOs etc. (also: text frames).

                Often objects that have no texts property.


                Uwe

                • 5. Re: within a text frame linked in the text frame remove
                  hamdifem Level 1

                  together add "\"

                  cause of the error

                   

                  var doc = app.activeDocument;  

                  app.findGrepPreferences = app.changeGrepPreferences = null;  

                  app.findGrepPreferences.findWhat = "~a";  

                  var found = doc.findGrep();  

                  for(var i =found.length-1;i>=0;i--)  

                  {  

                          var ip = found[i].insertionPoints[0];  

                          if(found[i].allPageItems[0].lines.length == 2)  

                          {  

                                  app.findGrepPreferences = app.changeGrepPreferences = null;  

                                  app.findGrepPreferences.findWhat = "(\\d)(\\r)(\\d)";  

                                  app.changeGrepPreferences.changeTo = "$1$3";   // $1\\$3  ?? 

                                  found[i].allPageItems[0].texts[0].changeGrep();  

                                  app.findGrepPreferences = app.changeGrepPreferences = null;  

                                  var cont = found[i].allPageItems[0].texts[0].duplicate(LocationOptions.AFTER,ip);  

                                  cont.characters[0].appliedCharacterStyle = doc.characterStyles.item("my character style 1");

                                  cont.texts[0].insertionPoints.item(1).contents = "\\"; \\ ??

                                  cont.characters[1].appliedCharacterStyle = doc.characterStyles.item("my character style 2");

                                  found[i].remove();

                              }  

                      }

                  • 6. Re: within a text frame linked in the text frame remove
                    hamdifem Level 1

                    How can I change second character

                    aA3.jpg