I also find myself repeatedly adding similar error handling code to my procedures and it can get a bit tedious to say the least. There is a VBIDE addin called MZTools that has the ability to add code snippets that you can easily embed in your code, including an error handler. The snippets allow the inclusion of placeholders, such as procedure name, so it can adapt to the target procedure. Earlier editions were free, but v8 does cost money, and I think it is a tad expensive, but it has lots of other functions, it is an option for you.
This is an example error handler, you can see how the placeholders work
Dim mpSettings As ApplicationSettings
Dim mpTopLevel As Boolean
Const mpProcedure As String = "{PROCEDURE_NAME}"
On Error GoTo {PROCEDURE_NAME}_Error
'can be a top-level call or initiated by another
mpTopLevel = IIf(IsArrayAllocated(mgVecProcStack), False, True)
PushProcedureStack mpProcedure, mpTopLevel
{PROCEDURE_NAME}= True
Call AppSettings(State:="Set", _
AppType:=mpSettings, _
AppEvents:=True, _
AppScreen:=True, _
AppAlerts:=False, _
AppCalc:=appNotEnabled)
{PROCEDURE_BODY}
{PROCEDURE_NAME}_Tidy:
PopProcedureStack
{PROCEDURE_NAME}_Tear_Down:
{PROCEDURE_NAME}_Exit:
Call AppSettings(State:="Reset", _
AppType:=mpSettings, _
AppEvents:=True, _
AppScreen:=True, _
AppAlerts:=False, _
AppCalc:=appNotEnabled)
Exit Function
{PROCEDURE_NAME}_Error:
If Err.Number = mgBypassErrorNum Then Resume {PROCEDURE_NAME}_Tear_Down
{PROCEDURE_NAME} = False
If AppErrorHandler(mmModule, mpProcedure, mpTopLevel) Then
Stop
Resume
Else
Resume {PROCEDURE_NAME}_Exit
End If
I have no connection with MZTools or the author, it is just a tool that I use and have gained value from.