From official documentation "CAA V5 Automation Coding Rules":
As a default behavior the interpreter will stop and display an error message box whenever an error is raised.
When you want to take corrective actions on an error, disabling the automatic error handing mechanism using "On Error Resume Next" becomes mandatory.
That means you should disable default error handling and instead write a custom logic using error object Err
.
Dim CATIA As Object
On Error Resume Next ' Disable automatic error handling
Set CATIA=GetObject(,"CATIA.Application")
iErr = Err.Number ' For BasicScript parser (Unix)
If (iErr <> 0) Then ' Manually handle all errors
On Error Goto 0 ' Invalidates the Resume Next and clears the error
set CATIA=CreateObject("CATIA.Application")
End If
On Error Goto 0 ' Invalidates the Resume Next and clears the error