1 Reply Latest reply on Feb 22, 2013 7:03 AM by dulajun

    How to specify character style to anchored objects markers depending on the objects formats?

    Advert_One

      I have a long document contains much of anchored text frames with custom positions and want to delete them by aplying character styles to their markers.

        • 1. Re: How to specify character style to anchored objects markers depending on the objects formats?
          dulajun Level 2

          Create a new character style to apply it. And change the character style name in this code to yours, then execute it.

           

          main ();
          function main (){
              app.findGrepPreferences = NothingEnum.NOTHING;
              app.findGrepPreferences.findWhat = "~a";
              var objectsArray = app.activeDocument.findGrep();
              for (var c = 0; c < objectsArray.length; c++) {
                  if (objectsArray[c].textFrames.length > 0) //The anchored object is a text frame
                  {
                      var targetTextFrame = objectsArray[c].textFrames.item(0);
                      var textFramePosition = targetTextFrame.anchoredObjectSettings.anchoredPosition;
                      if (textFramePosition == AnchorPosition.ANCHORED) // the object have custom position
                      {
                          //Create a new charater style and change the character style name to yours.  
                          objectsArray[c].appliedCharacterStyle = app.activeDocument.characterStyles.itemByName("Delete");
                      }
                  }
              }
          }
          

           

          Then make a GREP search for this character style, and if you want delete them all by Change All button.