On Error / End Error

 

These commands are inserted directly into the script as there is not an edit window associated with them. From the Script Editor click on the Debug category of commands to expand the category. Then select either the On Error or End Error command to insert into the script.

 

The On Error command signals to the macro that action needs to take place if an error occurs with the macro command immediately preceding the On Error  command during playback. This command is used in conjunction with the Catch Error message. Inserting the On Error and End Error commands without using the Catch Error command does nothing during macro playback. The commands will be ignored.

 

Note: The On Error command must immediately follow the macro command that it is checking for errors. For example, a comment is not allowed between that command and the On Error command.

 

The End Error command closes the error handling sequence and must be paired with the On Error command. The commands in the Script Editor would look similar to the example illustrated below.

 

 

Sample Macro - On Error Syntax

 

On Error

  Catch Error: The window could not be found

    Insert macro commands here to handle the error.

  End Catch Error

End Error