Look for a figure, if you find one, click on it. If not, terminate the macro

See If {picture} then {do this}