2 Replies Latest reply on Apr 28, 2009 8:04 PM by jw24

    Applescript to apply a paragraph style

    jw24

      I have to following applescript, and all I want to do is run a seach for a few lines and change the paragraph style that is applied to them.  When I run the script, I get the following error:  "Error String: Adoby InCopy CS3 got an error: Can't get paragraph style "~Paragraph1".  Can anyone help me get this working?

       

      I have this working with a regular find/change .xml, but need to string together about 5 or 6 different find/change results into one step (without using find/change by list).  Thanks for any input!

       

       

      tell application "Adobe InCopy CS3"
          --Clear the find/change preferences.
          set find text preferences to nothing
          set change text preferences to nothing
          --Remove the first four lines of the document
          set find what of find text preferences to "^pLine one here^pLine two here^pLine three here^p"
          --Set the find options.
          set case sensitive of find change text options to false
          set include footnotes of find change text options to false
          set include hidden layers of find change text options to false
          set include locked layers for find of find change text options to false
          set include locked stories for find of find change text options to false
          set include master pages of find change text options to false
          set whole word of find change text options to false
          --set the paragraph style of the found text
          set myStyle to paragraph style "~Paragraph1"
          set applied paragraph style of change text preferences to myStyle
          --run the change
          tell document 1
              change text
          end tell
          --Clear the find/change preferences after the search.
          set find text preferences to nothing
          set change text preferences to nothing
      end tell

        • 1. Re: Applescript to apply a paragraph style
          jw24 Level 1

          Hey all - I got this fixed, just wanted to post a version that works in case anyone else is having the same problem.

           

           

          tell application "Adobe InCopy CS3"
              --Clear the find/change preferences.
              set find text preferences to nothing
              set change text preferences to nothing
              --Remove the first four lines of the document
              set find what of find text preferences to "^pLine one here^pLine two here^pLine three here^p"
              --Set the find options.
              set case sensitive of find change text options to false
              set include footnotes of find change text options to false
              set include hidden layers of find change text options to false
              set include locked layers for find of find change text options to false
              set include locked stories for find of find change text options to false
              set include master pages of find change text options to false
              set whole word of find change text options to false
              --set the paragraph style of the found text
               set applied paragraph style of change text preferences to "StyleHere"
              --run the change
              tell document 1
                  change text
              end tell
              --Clear the find/change preferences after the search.
              set find text preferences to nothing
              set change text preferences to nothing
          end tell

          • 2. Re: Applescript to apply a paragraph style
            jw24 Level 1

            forgot to mark it answered...