Catch Error / End Catch Error


The Catch Error command is used to handle potential errors during the playback of a macro.


Practically all macro commands have an On Error tab. This tab provides several options for handling a potential error. The Catch Error command is available for use with either the Prompt for Action or Handle Error options. The other On Error tab options ignore the Catch Error command or halt the macro before encountering the Catch Error command in the script.



Script Editor > Expand Debug Category > Catch Error



If there is a possibility that one of the commands in the macro may fail because of a network error, a file not found error, a window did not open failure, etc. then one option is to use the Catch Error command.


Of course another option is to simply allow the macro to stop if the error occurs. But it may be preferable to have the macro take specific corrective action using the Catch Error command. The box below illustrates how this command is used in the Script Editor. This set of commands is placed immediately after the command chosen to handle the error.


Between the Catch Error and End Catch Error commands insert the macro commands to handle the error. This may include a corrective action to allow the macro to continue. Or insert an entire alternate script and end the macro before it can finish the entire script by using the Macro Stop command.



Sample Macro - Catch Error Syntax


Window Activate: xyz

On Error

  Catch Error: The window could not be found

    Insert macro commands here to handle the error.

  End Catch Error

End Error





List of errors available for handling

Array is too small

Cannot close the macro file

Cannot create the specified folder

CD command could not be executed

Clipboard does not contain a graphic image

Command completed successfully

Condition was not met within the specified amount of time

Control doesn't exist

Could not access the specified registry value

Could not locate the text cursor

Could not lock the workstation

Could not place the system into hibernation mode

Could not retrieve the Terminal Services Session ID

Could not write to the INI file

Dialog was cancelled

Dial-up connection was not established

Divide by Zero

File could not be created

File could not be located

File could not be opened

File format is unsupported

File is not the correct format

Files required for Dial-Up Networking are not installed

Invalid Date/Time value

Invalid Input

Label does not exist

Macro does not exist

Macro file is already loaded

Macro is locked by another user

Macro was halted

Maximum is smaller than the minimum

Message could not be sent

Network error

Notification area icon does not exist

Operation was not completed

Path does not exist

Process could not be terminated

Process is not running

Program could not be launched

Registry key cannot be created

Registry key cannot be deleted

Registry value does not match the variable type

Requested feature is not supported

Resolution is unsupported

SMTP connection failed

Specified date/time is not supported by the file system

Specified printer does not exist

Text being waited for is too long

There are currently no IP addresses assigned to this computer

There are no Internet Explorer windows to watch

There is no control to capture

Unable to access clipboard

Undefined Variable

Window could not be found