11 Replies Latest reply on Nov 19, 2014 12:16 PM by Trevorׅ

    How do I apply style within a text frame linked object

    hamdifem Level 1

      I'm selecting the text frame in the object I want to apply an object style

      A script can be written

      within a text frame the linked object (selected text frame)

      how object style is applied

       

      Başlıksız-4.jpg

        • 1. Re: How do I apply style within a text frame linked object
          Trevorׅ Adobe Community Professional

          Hi

           

          All you need is

           

          app.selection[0].appliedObjectStyle = app.activeDocument.objectStyles.itemByName ("Trevors Object Style");
          

           

          The below snippet will apply the style to all the anchored objects in the selection or document

           

          var doc = app.properties.activeDocument,
              myOnjectStyle = doc.objectStyles.itemByName ("Trevors Object Style"),
              myObjects, l;
          if (!myOnjectStyle.isValid) {
              alert ("Either add an Object Style Called:\nTrevors Object Style\nOr Make Significant Changes to The Script");
              quit ();
          }
          app.findTextPreferences = app.changeTextPreferences = null;
          app.findTextPreferences.findWhat = "^a";
          myObjects = (app.selection && app.selection[0]).findText () || doc.findText ();
          l = myObjects.length;
          while(l--) myObjects[l].textFrames[0].appliedObjectStyle = myOnjectStyle;
          

           

          HTH

           

          Trevor

          • 2. Re: How do I apply style within a text frame linked object
            hamdifem Level 1

            thank you my Script you can edit?

            This script all page and all text frame run

            but I'm just select the text frame

             

            main ();

            function main(){

              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

                if(app.documents.length >= 1){

                    var myDocc=app.activeDocument;

                    embeddd()

                }else{

                    alert("pleace select");

                    }

            }

             

            function embeddd(){

                var frameNoo=0

                var toplamSayi=app.activeDocument.activeLayer.textFrames.length

               

                    for (var i=0;   i <toplamSayi; i++){ 

                        var islenecekTextFrame=app.activeDocument.activeLayer.textFrames.item(i)

                            for (var j=0;   j <app.activeDocument.activeLayer.textFrames.item(i).pageItems.length; j++){ 

                                var myNewFrame=app.activeDocument.activeLayer.textFrames.item(i).pageItems.item(j);

                               myNewFrame.appliedObjectStyle = myObjectS;

                               frameNoo++

            }

            }

            }

            • 3. Re: How do I apply style within a text frame linked object
              Trevorׅ Adobe Community Professional

              Sorry I couldn't understand your English.

              Try to explain what you need more clearly

              • 4. Re: How do I apply style within a text frame linked object
                hamdifem Level 1

                only I selected within a text frame

                I want to apply to objects

                 

                var myTextFrame =app.activeDocument.selection[0].textFrames.length

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

                myTextFrame.item(i).appliedObjectStyle = app.activeDocument.objectStyles.itemByName = myObjectStyle1;

                }

                • 5. Re: Re: How do I apply style within a text frame linked object
                  Trevorׅ Adobe Community Professional

                  Still not too sure what exactly you want but this should do it.

                  var doc = app.properties.activeDocument,
                      myObjectStyle = doc.objectStyles.itemByName ("Trevors Object Style"),
                      myObjects, l,
                      mySelection = app.selection;
                  if (!myOnjectStyle.isValid) {
                      alert ("Either add an Object Style Called:\nTrevors Object Style\nOr Make Significant Changes to The Script");
                      quit ();
                  }
                  if (!mySelection) {
                      alert("NoSelection\nHave a nice day");
                      quit ();
                      }
                  mySelection = mySelection[0];
                  app.findTextPreferences = app.changeTextPreferences = null;
                  app.findTextPreferences.findWhat = "^a";
                  if (mySelection.properties.parentTextFrames) myObjects = mySelection.properties.parentTextFrames[0].findText ();
                  else if (mySelection instanceof TextFrame) {
                      myObjects = mySelection.findText();
                      if (mySelection.parent.hasOwnProperty("baseline")) myObjects = myObjects.concat.apply(mySelection.parent.findText ());
                  }
                  else myObjects = "";
                  
                  l = myObjects.length;
                  while(l--) myObjects[l].textFrames[0].appliedObjectStyle = myObjectStyle
                  
                  • 6. Re: How do I apply style within a text frame linked object
                    hamdifem Level 1

                    text frames in at the same time rectangle is embedded fails

                    • 8. Re: How do I apply style within a text frame linked object
                      Trevorׅ Adobe Community Professional

                      Change the textFrames[0] to pageItems[0] on the last line

                      • 9. Re: How do I apply style within a text frame linked object
                        Trevorׅ Adobe Community Professional

                        P.s. You can either select the particular textframe you want to apply the style to or to the parentTextFrame or to a word in the parentTextFrame

                        • 10. Re: How do I apply style within a text frame linked object
                          hamdifem Level 1

                          very simple

                          ok

                          separately, different style to the text frame (myobjectstyle1)

                          rectangle separate style (myobjectstyle2)

                          I want to apply. How do we do

                          • 11. Re: How do I apply style within a text frame linked object
                            Trevorׅ Adobe Community Professional

                            make myObjectStyles into an array i.e.

                             

                            myObjectStyles = [

                                            doc.objectStyles.itemByName ("Trevors Object Style"),

                                            doc.objectStyles.itemByName ("Trevors Object Style2")

                                        ]

                             

                            Then in the last line

                            while(l--) myObjects[l].pageItems[0].appliedObjectStyle = myObjectStyles[l % myObjectStyles.length]