3 Replies Latest reply on Oct 10, 2009 12:59 PM by jay fresno

    Adding an object style to a paragraph style

    jay fresno Level 1

      I'm posting this on the InDesign scripting forum because I don't see any built-in feature in InDesign that would allow for this. I have paragraphs with small inline pictures. In order to position the pictures correctly and give them the correct frame stroke, I created an Object Style for them. Is there a way to build an object style into a paragraph style so that it is automatically applied -- or is that too much to hope for?

        • 1. Re: Adding an object style to a paragraph style
          Kasyan Servetsky Level 5

          I don't know if it's possible to set this as default in ID, but you can try this script:

           

          var myDoc = app.activeDocument;
          // type the name of your object style in the line below
          var myObjStyle = myDoc.objectStyles.item("Inline Style");

           

          for (i = 0; i < myDoc.stories.length; i++) {
              var myStory = myDoc.stories[i];
              for (j = 0; j < myStory.allGraphics.length; j++) {
                  var myImage = myStory.allGraphics[j];
                  myImage.parent.appliedObjectStyle = myObjStyle;
              }
          }

          • 2. Re: Adding an object style to a paragraph style
            jay fresno Level 1

            Kasyan,

            Thank you for replying to my post. The script would be a great time saver if I can get it to work. However, the script isn't changing anything, nor is it giving an error message. Do I need to follow a certain procedure for it to work -- like select a frame first, or highlight text first? I tried selecting and not selecting, but still nothing happens when double-clicking the script.

            • 3. Re: Adding an object style to a paragraph style
              jay fresno Level 1

              Kasyan,

               

              I do apologize for my earlier post -- and thank you profusely for the script.  IT DOES WORK!

               

              The script changes every inline graphic in the active open document to the specified object style, which works perfectly for the project I'm working on at this time, although the project may later evolve to include more object styles. I assume that the script must apply to a whole document and can't be adjusted to apply the object style to a portion of a document. I'm always amazed at what a talented script writer can do.