1 Reply Latest reply on Aug 1, 2015 1:49 AM by greenrookie

    How to relink an image on the active page in InDesign using ApplesScipt

    Dave_Guerrero

      So I have to make contact sheets at work often and I'm trying to make a script that will replace an image with a specific one.

      I have gotten this script to do it, but i want it to do it on the page that is currently active, not just Page 1 of the file.

       

      Here is my code:

      !

      tell application "Adobe InDesign CC 2014"

          tell active document

              set myPage to active page

              relink link "Logo.png" to alias "F3-PLA:03_jobs:ABCCABLE.1127777:ASSETS:Templates:Logos_CS:XD:Logo.png"

              try

                  update link "Logo.png" --sometimes the new link comes up modified. I don't know why.

              end try

          end tell

      end tell

      !

        • 1. Re: How to relink an image on the active page in InDesign using ApplesScipt
          greenrookie Level 2

          Try this.

           

          This will only relink items on active page.

           

           

          tell application "Adobe InDesign CC 2014"

                        set myFinalfile to "F3-PLA:03_jobs:ABCCABLE.1127777:ASSETS:Templates:Logos_CS:XD:Logo.png"

                        tell active document

                                       set myActivePage to active page of layout window 1

                                       set myLinks to {}

                                       set grphicBoxes to all graphics of myActivePage

                                       repeat with i in grphicBoxes

                                                     set iLink to (item link of i whose name contains "Logo.png")

                                                     set end of myLinks to iLink

                                                     repeat with j in myLinks

                                                                    relink j to alias myFinalfile

                                                     end repeat

                                       end repeat

                        end tell

          end tell

           

           

          greenrookie