2 Replies Latest reply on Jun 9, 2008 8:13 PM by (Kari_Puikkonen)

    AppleScript: Access nor allowed?!

      I bumped in to the error that I haven't seen before.

      When I run this script

      I get this error:

      Cant get (selected index of myPresetsDropdown) + 1. Access not allowed.

      on this line:

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

      What might be wrong?!

      tell application "Adobe InDesign CS3"
      
      set find text preferences to nothing
      set change text preferences to nothing

      set myDoc to active document

      set myParaList to name of every paragraph style of myDoc
      set myCharList to name of every character style of myDoc

      set myDialog to make dialog with properties {name:"Choose paragraph style and change case"}
      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", 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
          tell (make dialog column)
           make static text with properties {static label:"Choose a character style", min width:150}
          end tell
          tell (make dialog column)
           set myCaseDropdown to make dropdown with properties ¬
            {string list:myCharList, selected index:0}
          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 myChar to item ((selected index of myCaseDropdown) + 1) of myCharList
      end if
      destroy myDialog

      tell myDoc
        
        set find text preferences to {applied paragraph style:paragraph style myPara, applied character style:character style myChar}
        set myFinds to find text

        repeat with i from (count of myFinds) to 1 by -1
         set theContents to (item i of myFinds)
         set contents of character after last character of theContents to return
        end repeat
      end tell

      end tell


      Kari