This example forces error 10, with a subsequent transfer to the TestError label. TestError tests the error and, if not error 55, resets Err to 999 (user-defined error) and returns to the Main subroutine. Sub Main()
????On Error Goto TestError
????Error 10
????MsgBox "The returned error is: '" & Err() & " - " & Error$ & "'"
????Exit Sub
TestError:
????If Err = 55 Then ??????'File already open.
????????MsgBox "Cannot copy an open file. Close it and try again."
????Else
????????MsgBox "Error '" & Err & "' has occurred."
????????Err = 999
????End If
????Resume Next
End Sub
|