0 Replies Latest reply on Jun 1, 2009 3:07 AM by Mr Bounce

    duplicate method (CS2 and CS3)

    Mr Bounce




      I asked a question about duplicating images from one document to another that didn't exist on the local drive anymore.


      I tried someones suggestion to duplicate the box containing the image, to the other document, then setting the new box's properties to match the target box and deleting the target box.




      That method works great with CS3 but the same code does not work with CS2 - just wanted to post my method to see if anyone could see why....



      (Before running this l've opened two documents with a rectangle labeled 'pic1' on both - l've only placed an image in doc 1's box)





      property myDocuments : {}

      set boxName to "pic1"



      tell application "Adobe InDesign CS3"

      -- tell application "Adobe InDesign CS2"


            -- Source

            tell active document

                  set MyRectangles to page item boxName

                  set MyRectangle to item 1 of MyRectangles

                  set thePage to parent of MyRectangle

                  set thePageNumber to name of thePage

            end tell


            if (count documents) = 0 then

                  display dialog "Please, open a document" buttons "OK" default button 1 with icon caution


                  repeat with d from 1 to count documents

                        set MyDocument to document d

                        set end of myDocuments to MyDocument

                  end repeat


            end if


            set docCount to the number of items in myDocuments


            repeat with x from 2 to docCount

                  set proceed to true

                  set myPasteDocument to (item x of myDocuments)


                  tell myPasteDocument


                        -- Target

                        set MyTargetRectangles to page item boxName

                        set MyTargetRectangle to item 1 of MyTargetRectangles

                        set theTargetPage to parent of MyTargetRectangle

                        set theTargetPageNumber to name of theTargetPage

                        set {y, x, l, h} to geometric bounds of MyTargetRectangle


                        -- LINE ONLY WORKS IN CS3 not CS2

                        set MyTargetRectangleCopy to duplicate MyRectangle to page theTargetPageNumber


                        -- DELETES FROM DOC2- CS3 and CS2 - OK

                        delete MyTargetRectangle


                        -- MOVE AND SET MOVES DUPLICATE ITEM on DOC1 - SHOULD BE ON DOC2

                        -- LINE ONLY WORKS IN CS3 not CS2

                        move MyTargetRectangleCopy to {x, y}

                        set geometric bounds of MyTargetRectangleCopy to {y, x, l, h}


                  end tell


            end repeat


      end tell



      Regards, Gary.