5 Replies Latest reply on Dec 23, 2010 2:50 AM by [Jongware]-9BC6tI

    moving a paragraph inside anchored text box...

    Green4ever Level 3

      Hi

      While i try to move the text inside the anchored text box it shows error is in the highlighted line...


      for (i=0; i<myFind.length; i++)
      {
          myText = myLib.assets.item ("REF").placeAsset (myFind[i].insertionPoints[-1])[0];
          myFind[i].move(LocationOptions.after, myText.insertionPoints[0]);
          myText.appliedObjectStyle = myDoc.objectStyles.item (myObjectStyle);
          myText.fit(FitOptions.frameToContent);
      }

      Picture 1.png

      Could any one help on this regard please.....

        • 1. Re: moving a paragraph inside anchored text box...
          Haakenlid Level 3

          Could it be that myText.insertionPoints[1] does not exist? That would be the case if myText contains no characters.

          • 2. Re: moving a paragraph inside anchored text box...
            Harbs. Level 6

            The error message does not match the code you posted.

             

            It's always advisable to use references to text in a Story rather than a TextFrame, because the latter can be overset and not have any valid insertionPoints...

             

            Harbs

            • 3. Re: moving a paragraph inside anchored text box...
              Green4ever Level 3

              Hi,

               

              I am giving my full codes here could you pls check and give some suggesstions..

              function myStyleDialog(){
              var myLabelWidth = 120;
              var myParaStyleNames = myGetParagraphStyleNames();
              var myObjStyleNames = myGetObjectStyleNames();
              var myDialog = app.dialogs.add({name:"Choose Styles to Place Anchor"});
              with(myDialog.dialogColumns.add()){
                  with(borderPanels.add()){
                      with(dialogColumns.add()){
                          with(dialogRows.add()){
                              with(dialogColumns.add()){
                                  staticTexts.add({staticLabel:"Paragraph Styles:", minWidth:myLabelWidth});
                              }
                              with(dialogColumns.add()){
                                  myParaStyleDropdown = dropdowns.add({stringList:myParaStyleNames, selectedIndex:0});
                                  }
                              }
                                  with(dialogRows.add()){
                                      with(dialogColumns.add()){
                                          staticTexts.add({staticLabel:"Object Styles:", minWidth:myLabelWidth});
                                          }
                                      with(dialogColumns.add()){
                                          myObjectStyleDropdown = dropdowns.add({stringList:myObjStyleNames, selectedIndex:0});
                          }
                      }
                  }
              }
                  myReturn = myDialog.show();
                  if(myReturn == true){
                       myParagraphStyle = myParaStyleNames[myParaStyleDropdown.selectedIndex];
                       myObjectStyle = myObjStyleNames[myObjectStyleDropdown.selectedIndex];
                       myDialog.destroy();
                       }
                    else {
                    myDialog.destroy();
                    }  
                  }
              }
              function myGetParagraphStyleNames(){
                  var myStyleNames = app.documents.item(0).paragraphStyles.everyItem().name;
                  return myStyleNames;
              }   
              function myGetObjectStyleNames(){
                  var myObjStyleNames = app.documents.item(0).objectStyles.everyItem().name;
                  return myObjStyleNames;
              }
              
               
              
              var myDoc = app.documents[0];
              var myLib = app.libraries[0];
              app.findTextPreferences = NothingEnum.nothing;
              app.changeTextPreferences = NothingEnum.nothing;
              app.findTextPreferences = null;
              app.findTextPreferences.appliedParagraphStyle=myParagraphStyle;
              
               
              
              myFind = myDoc.findText(true);
              var myCount=0;
              for (i=0; i<myFind.length; i++)
              {
                  myText = myLib.assets.item ("ANNO").placeAsset (myFind[i].insertionPoints[-1])[0];
                   myFind[i].move(LocationOptions.after, myText.insertionPoints[0]);
                   myText.appliedObjectStyle = myDoc.objectStyles.item (myObjectStyle);
                   myText.fit(FitOptions.frameToContent);
                  myCount++;
              }
              
               
              
              alert(myCount+" ANNOs are Placed Successfully...");
              

               

              One more information: This script is done with reference to the CS3 reference, But i'm working in CS4. May this will be a problem because of some object model has been upgraded in CS4?

               

              Hi can anyone Help..... Message was edited by: Green4ever

              • 4. Re: moving a paragraph inside anchored text box...
                Green4ever Level 3

                Hi All please check this and give any suggestions......    

                • 5. Re: moving a paragraph inside anchored text box...
                  [Jongware]-9BC6tI Level 4

                  I can't find that line #84 in your code; neither by counting (your "full codes" has only 71 lines), nor by looking for the line that triggered the error ("myFind[i].move(LocationOptions.after, myText.insertionPoints[1]);").

                   

                  You are making it hard to help you.