6 Replies Latest reply on Dec 18, 2015 10:03 AM by rob day

    [Applescript] Adobe Indesign CC 2015: Document 1 can not be requested

    bend50336919

      I've used the script below to export pdf files for a few years. Since CC the script does not work correct anymore.

       

      If i start indesign select a couple of indesign files in the browser and let the script run it works fine. If i run the script again i will get an script error "Adobe InDesign CC 2015 got an error: document 1 cannot be requested.".

       

      If i shut down indesign en restart it the script workt fine again for 1 time, then i have to restart it again.

       

      Can anyone give me some help with this problem.

       

      tell application "Finder"

          set myfiles to the selection

      end tell

       

      tell application "Adobe InDesign CC 2015"

          activate

          repeat with i in myfiles

              open i

            

              --THIS PRESET NAME SHOULD BE PRESENT IN InDesign!!

              --CHECK: file -> PDF export presets

              set thePreset to "PDFX4 2008"

            

              set theDesk to path to desktop as string

              set f to (name of i as string)

              set thepath to theDesk & f

            

              export document 1 to file (thepath & ".pdf") format PDF type using PDF export preset thePreset without showing options

            

              close active document saving no

          end repeat

      end tell

        • 1. Re: [Applescript] Adobe Indesign CC 2015: Document 1 can not be requested
          Kevin Parrott Level 2

          just tried it here  OSX10.11.2,   ID CC 2015, on three ID files about 10 times, work's fine for me, zero error's

          • 2. Re: [Applescript] Adobe Indesign CC 2015: Document 1 can not be requested
            Ronald63 Level 4

            try to replace ...

             

            export document 1 to file (thepath & ".pdf") format PDF type using PDF export preset thePreset without showing options
            

             

            by

             

            export active document to file (thepath & ".pdf") format PDF type using PDF export preset thePreset without showing options
            
            • 3. Re: [Applescript] Adobe Indesign CC 2015: Document 1 can not be requested
              Ronald63 Level 4

              and add "activate" for finder.

              tell application "Finder"
                  activate
                  set myfiles to the selection
              end tell
              
              • 4. Re: [Applescript] Adobe Indesign CC 2015: Document 1 can not be requested
                bend50336919 Level 1

                This does make it better. Although it does not seem consistent. Sometimes i get the error "Adobe InDesign CC 2015 got an error: There are no documents open". If i run the script again with 1 indesign file selected it works again, and after i do that it works for multiple indesign files as well. Very strange but this is a workable for me so thx for the solution.

                 

                Hmmm i just tried the original script on an identical mac and have no problem at all.

                • 5. Re: [Applescript] Adobe Indesign CC 2015: Document 1 can not be requested
                  david_p Level 1

                  Try replacing "set thePreset to "PDFX4 2008" with the following:


                  set thePreset to "[PDF/X-4:2008]"


                  Also, make sure that the files you want to process are selected in the frontmost window of Finder.


                  You may also consider adding a short delay before the export line in case the file hasn't opened before the export command is run.

                  • 6. Re: [Applescript] Adobe Indesign CC 2015: Document 1 can not be requested
                    rob day Adobe Community Professional & MVP

                    This version does a couple of things that I think will help. Sets the file path as a string (which should solve the missing document problem), sets view PDF to false so all the PDFs don't open while the script runs, and closes the docs as they get exported. You can also add without showing window if you want the script to run in the background.

                     

                     

                    -----------------------------------------

                    tell application "Finder"

                        set myfiles to the selection

                        set theDesk to path to desktop as string

                      

                        tell application "Adobe InDesign CC 2014"

                            set thePreset to "[PDF/X-4:2008]"

                            repeat with x in myfiles

                                try

                                    -- NOTE: file path needs to be a string

                                    set myDoc to open (x as string)

                                    --this makes the process hidden

                                    --set myDoc to open (x as string) without showing window

                                    --strip ID ext.

                                    set n to name of myDoc

                                    set n to characters 1 thru -6 of n as string

                                    set thePath to (theDesk & n & ".pdf")

                                    set view PDF of PDF export preferences to false

                                    export myDoc format PDF type to thePath using PDF export preset thePreset without showing options

                                    close myDoc saving no

                                end try

                            end repeat

                        end tell

                    end tell