Resuming Execution After an Error

Once you have handled an error, what happens with program execution? It is very rarely appropriate to let execution simply exit the procedure, which is what would happen by default as the error-handling code is typically placed at the end of the procedure. You can control where execution resumes with the Resume statement. This statement comes in three varieties:

  • Resume causes execution to resume with the statement that caused the error. Use Resume when you want to retry the operation that caused the error. This would be appropriate, for example, if the error was caused by having no diskette in a diskette drive; you can prompt the user to insert the diskette and then try again.

  • Resume Next causes execution to resume ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.