1 Reply Latest reply on Mar 3, 2013 6:07 AM by Muppet Mark

    Replace text with image using Applescript in InDesign CS5

    newscripter

      Hi to everyone, i'm looking for some suggestions to resolve my problem.
      I've to replace some strings with jpeg images stored on my pc

       

      Here is the code to replace two strings with the new ones.

       

      tell application "Adobe InDesign CS5"

       

                set myDocument to active document

                set myPage to page 1 of myDocument

       

                set stringsToReplace to {"111", "222"}

       

        repeat with iterator from 1 to (count stringsToReplace)

             set find text preferences to nothing

             set change text preferences to nothing

             set myFoundItems to nothing

       

             set element to item iterator of stringsToReplace

       

            if element is "111" then

                 set find what of find text preferences to "111"

                 set change to of change text preferences to "ONE"

                 set myFoundItems to change text

                 display dialog ("Found : " & (count myFoundItems) & " occurences of " & element)

            else if element is "222" then

                 set find what of find text preferences to "222"

                 set change to of change text preferences to "TWO"

                 set myFoundItems to change text

                 display dialog ("Found : " & (count myFoundItems) & " occurences of " & element)

            end if

                end repeat

       

        set find text preferences to nothing

        set change text preferences to nothing

       

      end tell

       

      Can you hel me?
      Thanks in advance.

        • 1. Re: Replace text with image using Applescript in InDesign CS5
          Muppet Mark Level 5

          Hello, I have a couple of questions for you… How come you have strings in text frames… Would you not be better off using labels for this…? ( thats how I would do this ). Off the top of my head I think you will need to remove any text content from the frame to be able to change it's content type… only then will you be able to place a graphic… How are you associating your strings with the required image files… Do you have this in some extenal file Excel or FMP.