SetAbort, SetComplete Methods Example

Dim ctxObject As ObjectContext
Set ctxObject = GetObjectContext()
On Error GoTo ErrorHandler

' Do some work here. If the work was successful,
' call SetComplete.
ctxObject.SetComplete
Set ctxObject = Nothing
Perform = 0
Exit Function

' If an error occurred, call SetAbort in the error 
' handler.
ErrorHandler:
    ctxObject.SetAbort
    Set ctxObject = Nothing
    Perform = -1
    Exit Function