7 Replies Latest reply on Apr 27, 2009 9:08 AM by wreyfmonkey

    Apply Smart Style Using Applescript

    wreyfmonkey

      Hi all,

       

      I am using the WoodWing plugin for applying smart styles to a document in InDesign CS3, but the syntax won't compile.  Here is my script:

       

      tell application "Adobe InDesign CS3"

          set theDoc to document 1
          set smartStyles to library "smartStyles.indl"

          set digestStyle to item "Digest" of assets of smartStyles
          apply smart style digestStyle to page item "Table Box"  of theDoc
      end tell

       

      The line "apply smart style digestStyle to page item "Table Box"  of theDoc" refuses to compile and I get this error: "Expected end of line, etc. but found identifier." and the word "smart" is highlighted.

       

      I took the syntax directly from the dictionary, which says:

      apply smart style v : Applies a the style of the asset to the passed item(s).
      apply smart style asset
      to page item : Page items to apply style to

       

      I have scoured the Internet, but only found a few references to InDesign CS syntax, which also won't compile in CS3.  I searched these forums but also found nothing.  I hate to post about a 3rd party plugin, but this is kind of my last-ditch effort for making this work.  If anyone has any ideas, I would greatly appreciate your input.  Thanks in advance!

        • 2. Re: Apply Smart Style Using Applescript
          Eric @ MCA Level 3

          Hmmm, can't tell if sstanley replied or not. It is blank on my screen right now.

           

          At any rate, I would suggest you need to do it on a per page basis.

           

          Something like: apply smart style digestStyle to page item "Table Box" of page 1 of theDoc

           

          FWIW, an excellent way to debug is to manually apply the smart style to the appropriate object, select the object and then run the script

           

          tell application "Adobe InDesign CS3"

          get properties of selection

          end

           

          That way, you can see all the attributes of the selected item, including its parent and exactly what the correct value is of the attribute you are trying to change.

           

          Then you undo and try and apply them via script.

          • 3. Re: Apply Smart Style Using Applescript
            sstanleyau Level 4

            >can't tell if sstanley replied or not

             

            He did, but the forum software ate it again.

             

            if the dictionary says "apply smart style asset", then smartStyles should be a reference to an asset, not a library as appears in the posted code.

            • 4. Re: Apply Smart Style Using Applescript
              wreyfmonkey Level 1

              Well, "digestStyle" is the variable for my asset from the library and "smartStyles" is the variable I used to refer to the library itself, so that really wouldn't matter if I switch them around since they are just variables.  Or am I missing something?  My thinking was that the dictionary more or less meant "apply smart style <insert asset name here>" ...hence the syntax I gave, "apply smart style digestStyle."  Does that make sense?  I appreciate the help!

              • 5. Re: Apply Smart Style Using Applescript
                wreyfmonkey Level 1

                Hi Eric,

                 

                Thanks for your reply.  "Reverse engineering" applying the smart style is a good suggestion and a technique I have used in the past with other scripts, but I did not think to use it here.  I will definitely try that when I get back to the office. Trying it one page at a time is also worth a shot, I think.  This is page 1 of a multipage document with linked text boxes, so I may try "parent story" and a few other tricks. 

                 

                If I'm still stuck, I'll post back on Monday.  Thanks to both of you for replying!

                • 6. Re: Apply Smart Style Using Applescript
                  sstanleyau Level 4

                  Yes, that makes sense -- I misread your original script.

                  • 7. Re: Apply Smart Style Using Applescript
                    wreyfmonkey Level 1

                    Eric,

                     

                    Nice work, man.  That was exactly it:

                     

                    apply smart style digestStyle to page item "Table Box" of page 1 of theDoc

                     

                    It's always something seemingly insignificant that makes the difference, isn't it?  Thanks to Eric for the answer and to both of you for your help!