Skip to main content
Inspiring
March 24, 2010
Question

[CS4][AS] Detect problems when opening document

  • March 24, 2010
  • 2 replies
  • 868 views

Hi,

Can anyone please help me?

I'm trying to write a applescript that opens a indesign file, prints the document, and closes the file again.

Everything works fine but when a file is opend, and there are some missing plugings, assignments, fonts, images, .... the script stops.

How can I  detect if a error appears when opening a file? The file then has to be ignored...

How can I detect if anything is missing before printing the file?

Thanks

the script:

tell application "Adobe InDesign CS4"

set myDocument to open inInputFile

print active document using "HighresPreset" without print dialog

close active document saving no

end tell

This topic has been closed for replies.

2 replies

Participant
March 24, 2010

You can ignore Dialogues altogether.

http://developer.apple.com/Mac/library/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_control_statements.html

March 24, 2010

Hello,

You can use:

try

set myDocument to open inInputFile

on error

display dialog "ERROR: can't open file."

return

end try

Inspiring
March 24, 2010

Hi:

Sometimes you may want your script to proceed even if there are errors opening it. In that case, you can use the Preferences Suite -> Script Preference for user interaction level:

tell application "Adobe InDesign CS4"

   tell script preferences

      return user interaction level -- see what it's set to currently

      --set user interaction level to never interact -- change it

   end tell

end tell

Inspiring
March 25, 2010

Hi,

Many thanks for your feedback. Setting the interaction level to "interact with alerts" was helpfull.