3 Replies Latest reply on Jun 25, 2014 6:59 PM by hasvi

    Pls correct my script for script label creation

    hasvi Level 1

      Hi,

       

      I want to add the script label name in Masterpages only which was in 'Text thread' options. Is this possible by script?

      This is my code

       

       

      var myTextFrame=app.selection[0];
      myTextFrame.label="textpage";
      var myNextFrame=myTextFrame.nextTextFrame;
      while(myNextFrame !=null)
      {
          myNextFrame.label="textpage";
          myNextFrame=myNextFrame.nextTextFrame;
          
      }
      
      
      Instead of first line I want to create this script label "textpage" for master page 'text thread' text frame only
      

      Instead of first line I want to create this script label "textpage" for master page 'text thread' text frame only. How to change my script pls help me?

       

      FYI:

      1.png

      by

      hasvi

        • 1. Re: Pls correct my script for script label creation
          Laubender Adobe Community Professional & MVP

          @hasvi – I don't know if I understand you right. Do you want to label every text frame of a story with the same label value? As a starting point you want to work with a selected text frame of that story?

           

          If yes, select a text frame, could be any, and run that snippet:

           

          var textContainersOfStoryArray = app.selection[0].parentStory.textContainers;
          
          for(var n=0;n<textContainersOfStoryArray.length;n++){
              textContainersOfStoryArray[n].label = "textpage";
              };
          

           

          Or do you mean you want to label the primaryTextFrame of the applied master spread, if you selected something on a "normal" page?

          That would be:

           

          //Object selected on "normal" page:
          var myPrimeryTextFrame = app.selection[0].parentPage.appliedMaster.primaryTextFrame;
          myPrimeryTextFrame.label = "textpage";
          

           

          Uwe

          • 2. Re: Pls correct my script for script label creation
            Chinnadk Level 4

            Hi Hasvi,

             

            Try this.

             

            var doc = app.activeDocument;
            var mspreads = doc.masterSpreads;
            
            for(var i =0;i<mspreads.length;i++)
            {
                    if(mspreads[i].textFrames.length>1)
                    {
                            var txfmlength = mspreads[i].textFrames;
                            for(var j=0;j<txfmlength.length;j++)
                            {
                                    if(txfmlength[j].nextTextFrame != null)
                                    {
                                        txfmlength[j].label="textpage";  
                                        }
                                    if(txfmlength[j].previousTextFrame !=null)
                                    {
                                            txfmlength[j].label="textpage";  
                                        }
                                }
                        }
                }
            

             

            Regards,

            Chinna

            • 3. Re: Pls correct my script for script label creation
              hasvi Level 1

              Hi chinna,

              thanks for your excellent work.

               

              by

              hasvi