When a macro encounters an error, it brings up the single-step error dialog box and displays details about the error. This can be confusing to end users, and it doesn’t allow the macro to finish any cleanup steps that might be included. By adding an error handling step and jumping over to another routine, your macros can handle errors in a more graceful manner.
- [Instructor] When a macro encounters an error,…it brings up the single step error dialog box…and displays details about the error.…We can see this by abusing a macro that I've created…called Simple Division.…Just going to scroll down and I'll double click on it…to run it.…It's going to bring up a couple of input boxes.…The first one will ask me for a numerator.…I'll just type in the number five.…I'll press enter and then it asks me for a denominator.…I'll type in the number two and press enter to that.…And then it returns a message box that says…5 divided by two equals 2.5.…So everything worked great there.…I'm just going to say OK and run that macro again.…
This time I'm going to enter in five as the numerator…and zero as the denominator.…This will generate a division by a zero error.…I'll say OK to that, and then it'll bring out…the Macro Single Step Window.…It'll tell me a bunch of information about the error…and I can Stop All Macros.…If I run that same macro again, and this time type in five…for the numerator and the letter A for the denominator.…
- Creating multi-step macros
- Triggering macros
- Running macros at startup
- Adjusting the execution and flow of macros
- Troubleshooting macros