10 Replies Latest reply on Jun 5, 2013 10:19 PM by Trevorׅ

    Pages sticking together after moving to a different document

    Lev Ger Level 1

      I've written an applescript which copies pages from several documents into one document. All pages in all ducuments are set to shuffle and all spreads also.

      For some bizzare reason when the pages are copied into the new document they all stick to one spread, and I have to manually break them up.

      I've searched around and can't see if I'm doing something wrong or if there is an InDesign bug I need to report. I've tried this script in CS5 and CS6.

      Appreciate any input.

       

      Here is the code:

       

      tell application "Adobe InDesign CS5"
          set AppleScript's text item delimiters to ""
          set mydocs to name of every document
          set MasterDoc to items of (choose from list mydocs with prompt "Select which document is the master document.")
          set MasterDoc to MasterDoc as string
          
          set master_hight to page height of document preferences of document MasterDoc
          set master_width to page width of document preferences of document MasterDoc
          
          set thesedocs to mydocs
          set mydocs to {}
          repeat with i in thesedocs
              set i to i as string
              if i ≠ MasterDoc then
                  set end of mydocs to i
              end if
          end repeat
          
          set Docstomerge to items of (choose from list mydocs with prompt "Select which documents you want to merge into the Master Document." with multiple selections allowed)
          
          set Docstomerge to my |sortlist|(Docstomerge)
          set mydoccount to 1
          repeat with this_doc in Docstomerge
              set myName to name of document this_doc
              set AppleScript's text item delimiters to "."
              set myName to text items 1 through -2 of myName as string
              set AppleScript's text item delimiters to ""
              set myName to myName as string
              
              set myPages to pages of document this_doc
              
              
              
              set aPages to duplicate every page of document this_doc to after last page of document MasterDoc
              set myBookMarkPage to item 1 of aPages
              
              tell document MasterDoc
                  
                  set myPageDest to make new hyperlink page destination with properties {destination page:myBookMarkPage, name:(("doc" & mydoccount) as string)}
                  make new bookmark with properties {destination:myPageDest, name:myName}
              end tell
                  
              close document this_doc saving no
              
              set mydoccount to mydoccount + 1
          end repeat
          display dialog "The merge was successful!"
      end tell
      
      on |sortlist|(the_list)
          set old_delims to AppleScript's text item delimiters
          set AppleScript's text item delimiters to {ASCII character 10} -- always a linefeed
          set list_string to (the_list as string)
          set new_string to do shell script "echo " & quoted form of list_string & " | sort -f"
          set new_list to (paragraphs of new_string)
          set AppleScript's text item delimiters to old_delims
          return new_list
      end |sortlist|