4 Replies Latest reply on Aug 16, 2011 11:12 PM by John Hawkinson

    Problem replacing content in text frame

    Gonterman1201 Level 1

      I am bumping my head against this. Its something I thought I know. I have a labeled text frame when I alert(mySpineTxt.getElements()); it tells me [object TextFrame] that sounds good to me then I use this


      if(mySpineTxt.getElements().length != 0){


      and it tells me that mySpineTxt does not support parentStory. I think it should.

      Please add any corrections that I am missing.

        • 1. Re: Problem replacing content in text frame
          Gonterman1201 Level 1

          mySpineTxt has a value of [object PageItem] if i write mySpineTxt.getElements() returns [object TextFrame] wich i need I think i just need a way of writing the relationship of this text box however insertionPoints and parentStory does not work because they are not supported by object PageItem. I don't know what the right choice is.

          • 2. Re: Problem replacing content in text frame
            Gonterman1201 Level 1

            In InDesign when you select the text box and go to menu object the content is grayed out. There would be no option for a menu command but I wonder why this is.

            • 3. Re: Problem replacing content in text frame
              Gonterman1201 Level 1

              #targetengine "session"
              //Creates a simple event listener.
              function main(){
                  var myEventListener = app.addEventListener("beforePrint", dateChanges, false);
                  var myEventListener = app.addEventListener("beforeSave", dateChanges, false);
                  //var myEventKill = app.addEventListener("beforeClose", killDate, false);
              function dateChanges(){
                   var myDocument = app.activeDocument;
              var myPageItems = myDocument.pageItems.item("myDateLabel");
              if(myPageItems.getElements().length != 0){
                  //alert ("I want to change your date")
                  var myDateText=myPageItems
              var myDate=new Date();
                                  contents=(    ""+myDate)
              }//ending bracket for dateChanges function
              function killDate(){
              app.removeEventListener("beforePrint", dateChanges, false);}


              this is an event listner that changes the date. This works when I use myDateText.parentStory when I plug it in to the other script i am using same stuff. it doesn't work its object is also listed as a page item.

              • 4. Re: Problem replacing content in text frame
                John Hawkinson Level 5

                I'm sorry, I can't quite tell what your question is.

                When posting code, please use >> Syntax Highlighting >> Java.

                Your first example is incomplete, we can't see how you have defined mySpineTxt, which makes it difficult to see the problem.

                Please post a self-contained example of the problem.

                Maybe a little more exposition, too, because your language is little hard to understand.