Excel VBA Global error handling

前端 未结 2 445
甜味超标
甜味超标 2020-12-17 01:26

Is there a way to do global error handling?

Can I put some code in the Workbook code that will catch any errors that occur within all modules?

I could put th

2条回答
  •  萌比男神i
    2020-12-17 01:51

    As Sid already mentioned in the comment, there is no central error handler.

    Best practice is to have a central error handling routine that gets called from the local error handlers. Take a look at the great MZ-Tools: it has the possibility to define a default error handler at the press of a button (Ctrl-E). You can customize this error handler - and it can also contain module and/or sub name!

    Additionally, check out this post at Daily Dose of Excel. It is Dick Kusleika's OO version of the error handler proposed in this book (which I can highly recommend).

提交回复
热议问题