1 Reply Latest reply on May 29, 2012 3:31 AM by Marcos Suárez

    TextFramePreference.insetSpacing

    Marcos Suárez Level 1

      Why this script not work?
      What do I have to do to run this script right?
      In the red line stops ...

       

      var myDocument = app.activeDocument;

       

      var myRegExp = ".+";

      app.findGrepPreferences = NothingEnum.nothing;

      app.changeGrepPreferences = NothingEnum.nothing;

      app.findGrepPreferences.appliedParagraphStyle = "_DESTACADOS";

      app.findGrepPreferences.findWhat = myRegExp;

       

      var myFoundItems = myDocument.findGrep(true);

       

      if(myFoundItems.length != 0){

            for(var myCounter = 0; myCounter < myFoundItems.length; myCounter ++){

                myFoundItem = myFoundItems[myCounter];

                myX1 = myFoundItem.characters.item(0).horizontalOffset;

                 myY1 = myFoundItem.characters.item(0).baseline;

                 myX2 = myX1 + 185;

                 myY2 = myY1 + 50;

                 

                  app.selection = myFoundItem;

                  app.cut();

                  myTextFrame = myDocument.textFrames.add();

                  myTextFrame.geometricBounds = [myY1, myX1, myY2, myX2];

                  app.selection = myTextFrame.insertionPoints[0];

                  app.paste();

                 myTextFrame.TextFramePreference.insetSpacing = ["12", "12", "12", "12"];

                  myTextFrame.fit(FitOptions.FRAME_TO_CONTENT);

          }         

      }