Exit_Handling is just a label. It's not a separate procedure. You can use lables with goto statements, but otherwise, they're ignored when a procedure is executed.
Printable View
Exit_Handling is just a label. It's not a separate procedure. You can use lables with goto statements, but otherwise, they're ignored when a procedure is executed.
Thanks a lot.
You must have an Exit Sub just before the handler label
That would work. Thanks.
Mr. Roarke, I think that depends on how you choose to handle things, but generally, most people follow this basic model:
[VBA] Function ProcedureName(ArgumentList) As DataType
' Procedure comments.
' Declare local variables and constants.
On Error GoTo ProcedureName_Err
' Procedure code.
.
.
.
ProcedureName = True (or some other return value)
ProcedureName_End:
' Cleanup code that closes open files and sets object variables = Nothing.
Exit Function
ProcedureName_Err:
ProcedureName = False
Select Case Err.Number
Case AnticipatedError#1
' Handle error #1.
Case AnticipatedError#2
' Handle error #2.
Case UnAnticipatedErrors
' Handle unanticipated error.
Case Else
' Handle unforseen circumstances.
End Select
Resume ProcedureName_End
End Function [/VBA]
For anyone interested, see http://msdn.microsoft.com/library/de...lingerrors.asp for more details.
Don't put exit sub before ex2.quit though. :whipQuote:
Originally Posted by JuanDelaCruz
Aye, xCav8r, I have seen and used that form as well. I suggested the simplest approach, based on the original code samples submitted. Thanks for the clarification, though.
Juan, if your problem is solved, can you use the link at the top of this thread (called Threat Tools) to mark this as solved?