7 Replies Latest reply on Nov 26, 2012 5:11 AM by sundar_r

    Placing anchor objects

    sundar_r

      Hi guys,

       

      I am just testing a script for a project, while executing, the following error occurs. Attached my snaps here for your reference.

       

      Target is: The document has the word "[H1]", this words needs to apply pstyle and replace with an anchor object. I had created the library assets too. I think I'm almost at the end. The execution is done for the first instance correctly, after that the error occurs as telling "Text cannot be moved to its current location"

       

      Here is my script:

       

      var mydoc=app.documents.item(0);

      app.findTextPreferences=null;

      app.changeTextPreferences=null;

      app.findTextPreferences.findWhat="[H1]";

      app.changeTextPreferences.appliedParagraphStyle="H1"

      app.changeText();

      var myfounds=mydoc.findText();

      var myLib=app.libraries.item(0);

      var myAssets=myLib.assets.item("H1");

       

       

      for (i=0;i<myfounds.length;i++) {

          myfound=myfounds[i];

         

          myAnchObj=myAssets.placeAsset(myfound.insertionPoints[0])[0];

          myfound.move(LocationOptions.after,myAnchObj.insertionPoints[0])

          //myAnchObj.appliedObjectStyle.name=="OBJ"

          }

       

      pic2.jpg

      pic1.jpg

      Hope you guys will clarify me. Thanks in advance.