-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVBA.ExcelErrorHandler.vb
More file actions
23 lines (21 loc) · 999 Bytes
/
VBA.ExcelErrorHandler.vb
File metadata and controls
23 lines (21 loc) · 999 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Public Sub DisplayMessage( _
ByVal procedure As String, _
ByVal module As String, _
errNbr As Double, _
errDes As String, _
Optional ByVal errLine As Variant = 0, _
Optional ByVal title As String = "Unexpected Error")
'--------------------------------------------------------------------------------------------------------------------
' Purpose: Global error message for all procedures
' Example: Call DisplayMessage("Module", "Procedure", 101, "descr", 1, "Error Description")
'--------------------------------------------------------------------------------------------------------------------
On Error Resume Next
Dim msg As String
msg = "Contact your system administrator."
msg = msg & vbCrLf & "Module: " & module
msg = msg & vbCrLf & "Procedure: " & procedure
msg = msg & IIf(errLine = 0, "", vbCrLf & "Error Line: " & errLine)
msg = msg & vbCrLf & "Error #: " & errNbr
msg = msg & vbCrLf & "Error Description: " & errDes
MsgBox msg, vbCritical, title
End Sub