3 Replies Latest reply on Aug 16, 2013 9:45 AM by Kari Puikkonen

    Apply paragraph to the next paragraph after the found  paragraph

    Kari Puikkonen

      A help would be appreciated!

       

      I can't understand who this script is not working.

      The idea is to find certain paragraph style and apply chosen (next) style to it.

      But nothing happens and i get this error: --> error number -1728

       

       

      Thanks in advance!

       

      tell application "Adobe InDesign CS6"

                set myDoc to active document

       

                set myParaList to name of every paragraph style of myDoc

                set myDialog to make dialog with properties {name:"Paragraph Styles"}

                tell myDialog

                          tell (make dialog column)

                                    tell (make border panel)

                                              tell (make dialog column)

        make static text with properties ¬

                                                                  {static label:"Choose a paragraph style before next style", min width:150}

                                              end tell

                                              tell (make dialog column)

                                                        set myPresetsDropdown to make dropdown with properties ¬

                                                                  {string list:myParaList, selected index:0, min width:150}

                                              end tell

                                    end tell

                                    tell (make border panel)

                                              tell (make dialog column)

        make static text with properties ¬

                                                                  {static label:"Choose a paragraph style of next style", min width:150}

                                              end tell

                                              tell (make dialog column)

                                                        set myPresetsDropdown2 to make dropdown with properties ¬

                                                                  {string list:myParaList, selected index:0, min width:150}

                                              end tell

                                    end tell

                          end tell

                end tell

                set myResult to show myDialog

                if myResult = true then

        -- +1 gets the correct name because list starts at 0

                          set myPara to item ((selected index of myPresetsDropdown) + 1) of myParaList

                          set mychangePara to item ((selected index of myPresetsDropdown2) + 1) of myParaList

                end if

        destroy myDialog

       

                set theStories to object reference of stories of myDoc

                repeat with theStory in theStories

                          try

                                    set theParaStyles to name of applied paragraph style of object reference of paragraphs of theStory

                                    repeat with x from 1 to (count of theParaStyles) - 1

                                              if myPara = contents of item x of theParaStyles then

        -- change the number accordingly

        applyPara(x + 1, theStory, mychangePara) of me

                                              end if

                                    end repeat

                          end try

                end repeat

      end tell

       

      on applyPara(paraNum, storyRef, mychangePara)

                tell application "Adobe InDesign CS6"

                          repeat

                                    set changeStyle to mychangePara

                                    set applied paragraph style of paragraph paraNum of storyRef to changeStyle

                                    exit repeat

                          end repeat

                end tell

      end applyPara