【发布时间】:2010-12-29 22:09:43
【问题描述】:
我有一个关于在 Excel 中处理 VBA 错误的正确方法的问题。如果发生特定错误,例如 xxxxxxx,则应显示 MsgBox。如果发生另一个错误,则应弹出标准运行时错误处理程序。如何实现?下面是示例代码:
On Error Resume Next
'Line of code that causes an error here.
If Err.Number = xxxxxxx Then
MsgBox "Specific error message."
ElseIf Err.Number = 0 Then
Do nothing
Else 'Some error other than xxxxxxx.
'This is the problem. Here I would like to display standard run-time error
'handler without causing the error again.
End If
On Error GoTo 0
【问题讨论】: