Error Handling - Adobe 23101335 - Photoshop - PC Manual

Scripting guide
Hide thumbs Also See for 23101335 - Photoshop - PC:
Table of Contents

Advertisement

2.10.4 Error handling

The following examples show how to stop a script from executing when a specific file cannot
be found.
AS
--Store a reference to the document with the name "My Document"
--If it does not exist, display an error message
tell application "Adobe Photoshop 7.0"
end tell
VB
Private Sub Command1_Click()
' Store a reference to the document with the name "My Document"
' If the document does not exist, display an error message.
DisplayError:
End Sub
Photoshop 7.0 Scripting Guide
try
set docRef to document "My Document"
display dialog "Found 'My Document' "
on error
display dialog "Couldn't locate document 'My Document'"
end try
Dim appRef As New Photoshop.Application
Dim docRef As Photoshop.Document
Dim errorMessage As String
Dim docName As String
docName = "My Document"
Set docRef = appRef.ActiveDocument
On Error GoTo DisplayError
Set docRef = appRef.Documents(docName)
MsgBox "Document Found!"
Exit Sub
errorMessage = "Couldn't locate document " & "'" & docName & "'"
MsgBox errorMessage
Scripting basics
Testing and troubleshooting
2
31

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop 7.0

Table of Contents