我们可以使用以下代码来避免这个问题:
tell application "Keynote" try open (choose file with prompt "Choose a Keynote file:") on error errMsg number errNum if errNum is not -128 then display dialog errMsg buttons {"OK"} default button "OK" with icon caution end if end try end tell
上述脚本使用了“try”和“on error”来处理错误。如果在打开PPTX文件时出现错误,则代码会显示错误消息对话框。